jabr / what-bus

An event-bus based on the WHATWG's BroadcastChannel API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what-bus

An event-bus based on the WHATWG's BroadcastChannel API.

The core module is a basic framework for creating, caching and clean-up of the underlying channel instances.

The cluster module is currently a work-in-progress, with the goal of coordination in a cluster of distributed WhatBus instances. Some implemented, partially complete, and planned features:

Example

import WhatBus from "./core.ts"
const wb = new WhatBus('wb:')

let s1 = wb.subscribe('t:1', event => console.log('s1', event.data))
wb.subscribeOnce('t:1', /* ... */)

wb.publish('t:1', { m: 100 })
wb.close()

import { create } from "./cluster.ts"
const wb = await create('twb:')
// @todo: cluster examples

References

License

This project is licensed under the terms of the MIT license.

About

An event-bus based on the WHATWG's BroadcastChannel API

License:MIT License


Languages

Language:TypeScript 100.0%