Function
Static Public Summary | ||
public |
cookiesync(key: string, action: function, handler: function): Object Creates a synchronizer which uses cookie polling to transmit objects to other tabs. |
|
public |
Creates a synchronizer which uses localStorage 'storage' event for synchronization between tabs. |
Static Public
public cookiesync(key: string, action: function, handler: function): Object source
import cookiesync from 'localsync/lib/cookiesync.js'
Creates a synchronizer which uses cookie polling to transmit objects to other tabs.
Params:
Name | Type | Attribute | Description |
key | string | The key to synchronize on. |
|
action | function | The action to run when trigger is executed. Should return the payload to be transmitted to the handlers on other tabs. |
|
handler | function | The handler which is executed on other tabs when a synchronization is triggered. Argument is the return value of the action. |
|
options.tracing | boolean |
|
Option to turn on tracing for debugging. |
options.logger | Object |
|
The logger to debug to. |
options.logLevel | string |
|
The log level to trace at. |
options.idLength | number |
|
The number of characters to use for unique instance ID. |
options.pollFrequency | number |
|
The frequency (in milliseconds) to poll at. |
options.path | string |
|
The path to store the cookie at. |
options.secure | boolean |
|
Flag to set the cookies secure flag. |
options.httpOnly | boolean |
|
Flag to set the cookies httpOnly flag. |
Return:
Object | cookiesync instance with start, stop, trigger, isRunning, isFallback, and instanceID properties. |
public localsync(key: string, action: function, handler: function): Object source
import localsync from 'localsync/lib/localsync.js'
Creates a synchronizer which uses localStorage 'storage' event for synchronization between tabs.
Params:
Name | Type | Attribute | Description |
key | string | The key to synchronize on. |
|
action | function | The action to run when trigger is executed. Should return the payload to be transmitted to the handlers on other tabs. |
|
handler | function | The handler which is executed on other tabs when a synchronization is triggered. Argument is the return value of the action. |
|
options.tracing | boolean |
|
Option to turn on tracing for debugging. |
options.logger | Object |
|
The logger to debug to. |
options.logLevel | string |
|
The log level to trace at. |