-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
subscriptions.ts
55 lines (48 loc) · 1.23 KB
/
subscriptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { IConnection } from './connections';
import { IdentifiedOperationRequest, OperationRequest } from './operations';
export interface ISubscriptionEvent {
event: string;
payload: any;
}
export interface ISubscriber {
event: string;
connection: IConnection;
operation: OperationRequest;
operationId: string;
}
export interface ISubscriptionManager {
/**
* Fetches all subscribers that listens to given event name and returns paged iterator
*
* @param name
*/
subscribersByEvent(event: ISubscriptionEvent): AsyncIterable<ISubscriber[]>;
/**
* Subscribes to events
*
* @param names event names
* @param connection
* @param operation
*/
subscribe(
names: string[],
connection: IConnection,
operation: IdentifiedOperationRequest,
): Promise<any>;
/**
* Unsubscribes from subscription
*
* @param subscriber
*/
unsubscribe(subscriber: ISubscriber): Promise<any>;
/**
* Unsubscribes client from specific subscription
*/
unsubscribeOperation(connectionId: string, operationId: string): Promise<any>;
/**
* Unsubscribes all subscriptions for connection id
*
* @param connectionId
*/
unsubscribeAllByConnectionId(connectionId: string): Promise<any>;
}