vuex-iframe-sync
Vuex state synchronization between iframe/window.
✨ Features:
- support iframes/window sync
- initialization sync when iframe loaded
- configure the sync behavior for your specific needs
? Requirements
Note window.postMessage has limition on message, works like JSON.parse() and JSON.stringfy().If you have trouble with it, configure a convert function in broadcast and transfer API.
? Installation
CDN
NPM
YARN
? Examples
? Usage
? API
broadcast(ids: String, [options])
Send state changes payload to iframes through postMessage API while parent state change.
ids <String|Array>
: frameIds split by ',' or [{id: iframeId, origin: iframeOrigin}...]
options
: The following options can be provided to configure the parent behavior for your specific needs:
convert <Function(payload)>
: convert payload before pass to iframes.
transfer([options])
Receive state changes from parent. Send state changes to parent while self state change.
options
: The following options can be provided to configure the iframe behavior for your specific needs:
convert <Function(payload)>
: convert payload before pass to parent.created <Function(id, store, send)>
: call after iframe created. id: iframeId、store: this.store、send<Function(type, payload)>:parent.$store.commitdestroyed <Function(id, store, send)>
: call after iframe destroyed. id: iframeId、store: this.store、send<Function(type, payload)>:parent.$store.commit
Build Setup
? Pending
- flexible configuration
- convert payload before pass to postMessage [√]
- ...
- test with jest [√]
- shim version