browser-messages
v1.0.1
Published
Message service for browser environment which encapsulates standart addEventListener, removeEventListener and CustomEvent, because of that it does not uses any external dependencies
Downloads
3
Readme
Messages
Message service for browser environment which encapsulates standart addEventListener, removeEventListener and CustomEvent, because of that it does not uses any external dependencies
How to install
npm install browser-messages
How to use
import messages from '/node_modules/browser-messages/main.js';
function onTest(event) {
const params = event.detail;
console.log(params);
}
//Subscribe on message test
messages.on('test', onTest);
//Send a message with parameters
messages.send('test', { hello: 'world' });
//Unsibscribe handler onTest from message test
messages.off('test', onTest);