Get unlimited public & private packages + team-based management with npm Teams.Learn more »

post-emitter

0.1.0 • Public • Published

Post Emitter

Talk between a iframe and parent window using events! This is just a wrapper around post message.

Usage

 
// top level document
 
var PostEmitter = require( 'post-emitter' ),
    emitter = new PostEmitter( {
        selector: 'iframe.embedded-content'
    } );
 
emitter.on( 'pong', function( msg ) {
    console.log( msg ); // foo
} );
 
emitter.emit( 'ping' );
 
 
// in iframe
 
var PostEmitter = require( 'post-emitter' ),
    emitter = new PostEmitter();
 
emitter.on( 'ping', function( msg ) {
    emitter.emit( 'pong', 'foo' );
} );
 
 

Install

npm i post-emitter

DownloadsWeekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar