2023-03-31 03:17:41 +02:00
|
|
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2023-09-21 10:57:37 +02:00
|
|
|
import type {
|
|
|
|
|
ContentTopic,
|
|
|
|
|
IAsyncIterator,
|
2023-11-14 21:22:52 +05:30
|
|
|
PubsubTopic,
|
2023-09-21 10:57:37 +02:00
|
|
|
Unsubscribe
|
|
|
|
|
} from "./misc.js";
|
2023-09-07 13:15:49 +05:30
|
|
|
import type { Callback } from "./protocols.js";
|
2023-03-31 03:17:41 +02:00
|
|
|
|
2023-11-14 21:22:52 +05:30
|
|
|
export type ActiveSubscriptions = Map<PubsubTopic, ContentTopic[]>;
|
2023-03-31 03:17:41 +02:00
|
|
|
|
|
|
|
|
export interface IReceiver {
|
2023-05-09 20:15:37 +02:00
|
|
|
toSubscriptionIterator: <T extends IDecodedMessage>(
|
2023-09-07 13:15:49 +05:30
|
|
|
decoders: IDecoder<T> | IDecoder<T>[]
|
2023-05-09 20:15:37 +02:00
|
|
|
) => Promise<IAsyncIterator<T>>;
|
2024-08-05 15:52:58 +05:30
|
|
|
subscribeWithUnsubscribe: SubscribeWithUnsubscribe;
|
2023-03-31 03:17:41 +02:00
|
|
|
}
|
2024-08-05 15:52:58 +05:30
|
|
|
|
|
|
|
|
type SubscribeWithUnsubscribe = <T extends IDecodedMessage>(
|
|
|
|
|
decoders: IDecoder<T> | IDecoder<T>[],
|
|
|
|
|
callback: Callback<T>
|
|
|
|
|
) => Unsubscribe | Promise<Unsubscribe>;
|