Basic UsageEdit this page on GitHub
Installation
Via npm
$ npm install across-tabs
Via bower
$ bower install across-tabs
Usage
Create an instance / reference before using.
Opener(Parent) tab*
var config = {
onHandshakeCallback: function () { ... },
onPollingCallback: function () { ... }
}
var parent = new AcrossTabs.Parent(config);
Constructor
accepts a configurable Object
with the following keys.
heartBeatInterval
: The time interval for polling tabs statusesremoveClosedTabs
: Pass it astrue
to have only opened tabs in the listshouldInitImmediately
: Pass it asfalse
to create an instance but initialize it lateronHandshakeCallback
: Callback to be called when a successful connection has been establishedonPollingCallback
: Callback to be called every time a tab is polled for its status
Config Keys | default | accepts |
---|---|---|
heartBeatInterval | 500 msec | A number representing milliseconds |
removeClosedTabs | false | Boolean |
shouldInitImmediately | true | Boolean |
onHandshakeCallback | Undefined | Function as callback |
onPollingCallback | Undefined | Function as callback |
New(Child tab)
var config = {
onReady: onReady,
onInitialize: onInitialize,
handshakeExpiryLimit: 4000, // msec
onParentDisconnect: onParentDisconnect,
onParentCommunication: onParentCommunication
};
var child = new AcrossTabs.Child();
Constructor
accepts a configurable Object
with the following keys.
handshakeExpiryLimit
: Time to wait for getting an acknowledgement from Parent window for child's requestonReady
: Callback to be invoked once child instance is readyonInitialize
: Callback when a child instance is actually initiatedonParentDisconnect
: Callback to be invoked when Parent gets disconnectedonParentCommunication
: Callback to be invoked whenevr Parent communicates with the child tab
Config Keys | default | accepts |
---|---|---|
handshakeExpiryLimit | 5000 msec | A number representing milliseconds |
onReady | Undefined | Function as callback |
onInitialize | Undefined | Function as callback |
onParentDisconnect | Undefined | Function as callback |
onParentCommunication | Undefined | Function as callback |