forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostal.d.ts
71 lines (53 loc) · 1.9 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
// Type definitions for Postal v0.8.9
// Project: https://github.com/postaljs/postal.js
// Definitions by: Lokesh Peta <https://github.com/lokeshpeta/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../underscore/underscore.d.ts" />
interface IConfiguration{
SYSTEM_CHANNEL: string;
DEFAULT_CHANNEL: string;
resolver: any;
}
interface ISubscriptionDefinition{
unsubscribe(): void;
subscribe(callback: (data: any, envelope: IEnvelope)=> void): void;
defer():ISubscriptionDefinition;
disposeAfter(maxCalls: number): ISubscriptionDefinition;
distinctUntilChanged(): ISubscriptionDefinition;
once(): ISubscriptionDefinition;
withConstraint(predicate: Function): ISubscriptionDefinition;
withConstraints(predicates: Array<Function>): ISubscriptionDefinition;
withContext(context: any): ISubscriptionDefinition;
withDebounce(milliseconds: number, immediate: boolean ): ISubscriptionDefinition;
withDelay(milliseconds: number): ISubscriptionDefinition;
withThrottle(milliseconds: number): ISubscriptionDefinition;
}
interface IEnvelope{
topic: string;
data?: any;
/*Uses DEFAULT_CHANNEL if no channel is provided*/
channel?: string;
timeStamp?: string;
}
interface IChannelDefinition {
subscribe(topic: string): ISubscriptionDefinition;
subscribe(topic: string, callback: (data: any, envelope: IEnvelope)=> void): ISubscriptionDefinition;
publish(topic: string, data?: any): void;
publish(envelope: IEnvelope): void;
channel: string;
}
interface IPostalUtils{
getSubscribersFor(channel: string, tpc: any): any;
reset(): void;
}
interface IPostal {
channel(name?:string): IChannelDefinition;
linkChannels(sources: IEnvelope | IEnvelope[], destinations: IEnvelope | IEnvelope[]): ISubscriptionDefinition[];
utils: IPostalUtils;
configuration: IConfiguration;
}
declare var postal: IPostal;
declare module "postal" {
var postal: IPostal;
export = postal;
}