forked from postaljs/postal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postal.d.ts
73 lines (61 loc) · 2.07 KB
/
postal.d.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Type definitions for PostalJS
// Project: https://github.com/postaljs/postal.js
// Definitions By: Bart Breen (https://github.com/barticus)
interface PostalEnvelope {
channel?: string;
topic: string;
timeStamp?: any;
data?: any;
}
interface PostalSubscriptionQuery {
channel?: string;
topic?: string;
context? : any;
}
interface PostalSubscriptionDefinition {
channel: string;
topic: string;
callback: (data: any, env: PostalEnvelope) => any
unsubscribe?();
}
interface PostalChannel {
channel: string;
topic?: string;
}
interface PostalChannelDefinition extends PostalChannel {
subscribe(topic: string, callback: (data: any, env: PostalEnvelope) => {}): PostalSubscriptionDefinition;
publish(topic: string, data: any);
publish(env: PostalEnvelope);
}
interface PostalSubscriptionCollection {
[channel: string]: PostalSubscriptionChannelCollection
}
interface PostalSubscriptionChannelCollection {
[topic:string]:PostalSubscriptionDefinition[]
}
interface PostalConfiguration {
resolver: any;
DEFAULT_CHANNEL: string;
SYSTEM_CHANNEL: string;
}
interface PostalStatic {
addWireTap(wireTap: (data: any, env: PostalEnvelope) => {}): any;
channel(channelName?: string): PostalChannelDefinition;
configuration: PostalConfiguration;
getSubscribersFor(options?: PostalSubscriptionQuery): PostalSubscriptionDefinition[];
linkChannels(source: PostalChannel, destination: PostalChannel): PostalSubscriptionDefinition[];
linkChannels(source: PostalChannel, destination: PostalChannel[]): PostalSubscriptionDefinition[];
noConflict(): PostalStatic;
publish(env: PostalEnvelope): PostalEnvelope;
reset();
subscribe(options: PostalSubscriptionDefinition): PostalSubscriptionDefinition;
subscriptions: PostalSubscriptionCollection;
unsubscribe(sub: PostalSubscriptionDefinition);
unsubscribeFor();
unsubscribeFor(PostalSubscriptionQuery);
wiretaps:(data: any, env: PostalEnvelope) => {}[];
}
declare module "postal" {
export = postal;
}
declare var postal: PostalStatic;