@apility/message-channel
v1.2.2
Published
Lets you connect to the Netflex MessageChannel API
Downloads
174
Keywords
Readme
Netflex MessageChannel client
Lets you connect to the Netflex MessageChannel API
Usage
import MessageChannel from '@apility/message-channel'
let channelKey = '00000000-0000-0000-0000-000000000000' // Can be generated server side, or provided manually
const channel = new MessageChannel(channelKey)
channel.on('message', message => console.log(message))
Promise based factory
You can alternatively use the static connect method
const channel = await MessageChannel.connect(channelKey, 'public')
Listening for a specific topic
const channel = new MessageChannel(channelKey, 'news')
// or
channel.on('connect', () => {
channel.setTopic('news')
})