post-msg
v1.0.5
Published
Post message made simple
Downloads
11
Readme
post-msg
Post message made simple
- Tiny
- 100% test coverage
- performant
Installation
npm install --save post-msg
Usage
var createPostMsg = require('post-msg')
var postMsg = createPostMsg(targetWindow, '*')
postMsg.on('*', log) // listen to all post messages from the targetWindow
postMsg.on('namespace', log) // listen for namespaced post messages from the targetWindow
postMsg.emit('hello', { data: true }) // send a post message to the targetWindow
postMsg.dispose() // remove all event and post message listeners
function log (type, data, origin, source) {
console.log(type, data, origin, source)
}