mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-09 09:13:10 +00:00
* chore: rename IReceiver subscribe * feat!: new `subscribe() API that only takes in decoders and callback * chore: `to_async_iterator` uses new function name * chore: make `createSubscription` private, and shorten error handling * chore: update subscribe return type * tests: use new API * fix: tests
23 lines
663 B
TypeScript
23 lines
663 B
TypeScript
import type { IDecodedMessage, IDecoder } from "./message.js";
|
|
import type {
|
|
ContentTopic,
|
|
IAsyncIterator,
|
|
PubsubTopic,
|
|
Unsubscribe
|
|
} from "./misc.js";
|
|
import type { Callback } from "./protocols.js";
|
|
|
|
export type ActiveSubscriptions = Map<PubsubTopic, ContentTopic[]>;
|
|
|
|
export interface IReceiver {
|
|
toSubscriptionIterator: <T extends IDecodedMessage>(
|
|
decoders: IDecoder<T> | IDecoder<T>[]
|
|
) => Promise<IAsyncIterator<T>>;
|
|
subscribeWithUnsubscribe: SubscribeWithUnsubscribe;
|
|
}
|
|
|
|
type SubscribeWithUnsubscribe = <T extends IDecodedMessage>(
|
|
decoders: IDecoder<T> | IDecoder<T>[],
|
|
callback: Callback<T>
|
|
) => Unsubscribe | Promise<Unsubscribe>;
|