TabLink
Dispatch data and events to other browser tabs on the same domain.
npm install tablink
API
Dispatching
Send a message to all other open tabs.
If the optional argument includeOwnTab
is set to true
,
the event will also be handled in the current tab doing the dispatching.
tablink;
type
A case-sensitive string representing the event type.
payload
A string or an object of data. Anything that can be sent through JSON.stringify/parse
.
includeOwnTab
Optional boolean. If true
, the event will also be handled on the current tab.
Example:
tablink;
Event listeners
tablink;
type
(String)
A case-sensitive string representing the event type to listen for.
listener
(Function)
A callback function that receives the payload
as its argument.
To remove the listener, invoke the function returned by on
.
Example:
let unsubscribe = tablink; // to stop listening;
Subscribing to all events
tablink
listener
(Function)
The callback to be invoked any time an action has been dispatched
Adds a change listener. It will be called any time any action is dispatched. To unsubscribe, invoke the function returned by subscribe.
Example:
let unsubscribe = tablink; // To unsubscribe;