forked from eejdoowad/mosi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.d.ts
37 lines (32 loc) · 918 Bytes
/
core.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
type Action = (arg: any, src: number) => any;
type ActionDetails = {
action: string;
arg?: any;
dst?: string;
}
/** Initializes Mosi's messaging system */
export declare function init(
config: {
log?: boolean;
subscriptions?: string[];
actions: { [key: string]: Action };
onConnect?: ActionDetails[];
onDisconnect?: ActionDetails[];
}
): void;
/** Message the target node(s) */
export declare function msg(target: number | string, action: string, arg?: any): void;
/** Message the target node(s) and fetches the response(s) */
export declare function get(target: number | string, action: string, arg?: any, timeout?: number): Promise<{
id: number
v?: any;
e?: any;
}[]>;
/** Returns information about a connection */
export declare function meta(connectionId: number): {
frameId: number
tabId: number
sender: chrome.runtime.MessageSender,
subs: string[],
data: any
}