Skip to content

Instantly share code, notes, and snippets.

@samdenty
samdenty / endpoint.ts
Last active July 4, 2020 21:21
comlink chrome extensions
import * as Comlink from 'comlink';
export const PORT_ID = '@@@PORT_ID';
const ports = new Map<string, chrome.runtime.Port>();
chrome.runtime.onConnect.addListener((port) => {
if (port.name.startsWith(PORT_ID)) {
ports.set(port.name, port);
}