post-msg

1.0.5 • Public • Published

Travis CI devDependency Status js-standard-style

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)
}

Readme

Keywords

Package Sidebar

Install

npm i post-msg

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

5.86 kB

Total Files

8

Last publish

Collaborators

  • alz