ofMessagePort

import { ofMessagePort } from '@hullo/browser'

Adapter for MessagePort, a communication endpoint of MessageChannel.

import { ofMessagePort } from './ofMessagePort';
const messageChannel = new MessageChannel();
window.open("/").postMessage("mch", "*", [messageChannel.port2]);
// listening setup
const port1 = ofMessagePort(messageChannel.port1);
port1.subscribe({
next(v) {
console.log("received", v);
}
});
// sending setup
port1.next({ message: "hello 👋" });