-
-
Notifications
You must be signed in to change notification settings - Fork 16
Broadcasting
By design, the localDataStorage interface sends custom events locally to the same tab/window in which the storage change event occurred. Yet equally as convenient, it also broadcasts to any other tabs or windows on the same origin via the Broadcast Channel API. In this way, browsing contexts can be kept in sync, if necessary.
(Web content's origin is defined by the scheme (protocol), hostname (domain), and port of the URL used to access it. Two objects have the same origin only when the scheme, hostname, and port all match.)
The default channel name is localDataStorage and can be renamed using the broadcast method. The channel name is stored in the channel property.
To listen on the channel, use code like this
const myChannel = new BroadcastChannel( 'localDataStorage' );
myChannel.addEventListener( 'message', (event) => {
console.log( event.data );
});
where the subscriber will receive a JSON detailing the change event, for example:
Array Keys:
push / pull, pullall poke contains where
Broadcasting:
broadcast
Data Transfer:
import / export
Duplicates:
countdupes, showdupes, listdupes
Internals:
cancrunch crunch / uncrunch
shufflestring / unshufflestring
Management:
keys
Memory Consumption:
Memory Quota:
showquota
Query:
haskey, hasval, hastype
setscramblekey / getscramblekey
Type Check:
isarray isbigint isboolean iscrunch
isdate isfloat isinteger isnull
Utility:
chopget copy softset rename
_set / _get _clear _key _remove
Management:
_keys
Type Check:
_isarray _isbigint _isboolean _iscrunch