@apility/message-channel

Lets you connect to the Netflex MessageChannel API

Usage no npm install needed!

<script type="module">
  import apilityMessageChannel from 'https://cdn.skypack.dev/@apility/message-channel';
</script>

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