npm.io
0.3.4 • Published 7 years ago

@repeaterjs/pubsub

Licence
MIT
Version
0.3.4
Deps
1
Size
17 kB
Vulns
0
Weekly
0
Stars
482
DeprecatedThis package is deprecated

@repeater/pubusb

This package is experimental!

A generic pubsub class, implemented with repeaters

For more information, visit repeater.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?: RepeaterBuffer<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?: RepeaterBuffer<T>): Repeater<T>;
  close(reason?: any): void;
}