@channel/pubsubdeprecated

A generic pubsub class, implemented with channels

Usage no npm install needed!

<script type="module">
  import channelPubsub from 'https://cdn.skypack.dev/@channel/pubsub';
</script>

README

@channel/pubusb

This package is experimental!

A generic pubsub class, implemented with channels

For more information, visit channel.js.org.

interface PubSub<T> {
  publish(topic: string, value: T): Promise<void> | void;
  unpublish(topic: string, reason?: any): Promise<void> | void;
  subscribe(topic: string, buffer?: ChannelBuffer<T>): AsyncIterableIterator<T>;
  close(reason?: any): Promise<void> | void;
}

class InMemoryPubSub<T> implements PubSub<T> {
  publish(topic: string, value: T): void;
  unpublish(topic: string, reason?: any): void;
  subscribe(topic: string, buffer?: ChannelBuffer<T>): Channel<T>;
  close(reason?: any): void;
}