forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backbone.radio.d.ts
92 lines (79 loc) · 5.89 KB
/
backbone.radio.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Type definitions for Backbone.Radio v0.8.3
// Project: https://github.com/marionettejs/backbone.radio
// Definitions by: Peter Palotas <https://github.com/alphaleonis/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare module Backbone {
interface Radio {
tuneIn(channelName: string): Radio;
tuneOut(channelName: string): Radio;
log(channelName: string, eventName: string, ...args: any[]): void;
channel(channelName: string): Radio.Channel;
}
module Radio {
var VERSION: string;
var DEBUG: boolean;
function log(channelName: string, eventName: string, ...args: any[]): void;
function tuneIn(channelName: string): Radio;
function tuneOut(channelName: string): Radio;
function channel(channelName: string): Channel;
// Proxy functions for Commands
function command(channelName: string, commandName: string, ...args: any[]): void;
function comply(channelName: string, commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
function comply(channelName: string, commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
function complyOnce(channelName: string, commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
function complyOnce(channelName: string, commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
function stopComplying(channelName: string, commandName?: string, callback?: (...args: any[]) => void, context?: any): Commands;
// Proxy functions for Requests
function request(channelName: string, requestName: string, ...args: any[]): any;
function reply(channelName: string, requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
function reply(channelName: string, commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
function replyOnce(channelName: string, requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
function replyOnce(channelName: string, commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
function stopReplying(channelName: string, commandName?: string, callback?: (...args: any[]) => any, context?: any): Requests;
// Proxy functions for Backbone.Events
function on(channelName: string, eventName: string, callback?: Function, context?: any): any;
function off(channelName: string, eventName?: string, callback?: Function, context?: any): any;
function trigger(channelName: string, eventName: string, ...args: any[]): any;
function bind(channelName: string, eventName: string, callback: Function, context?: any): any;
function unbind(channelName: string, eventName?: string, callback?: Function, context?: any): any;
function once(channelName: string, events: string, callback: Function, context?: any): any;
function listenTo(channelName: string, object: any, events: string, callback: Function): any;
function listenToOnce(channelName: string, object: any, events: string, callback: Function): any;
function stopListening(channelName: string, object?: any, events?: string, callback?: Function): any;
class Commands {
command(commandName: string, ...args: any[]): void;
comply(commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
comply(commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
complyOnce(commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
complyOnce(commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
stopComplying(commandName?: string, callback?: (...args: any[]) => void, context?: any): Commands;
}
class Requests {
request(requestName: string, ...args: any[]): any;
reply(requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
reply(commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
replyOnce(requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
replyOnce(commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
stopReplying(commandName?: string, callback?: (...args: any[]) => any, context?: any): Requests;
}
class Channel extends Backbone.Events implements Commands, Requests {
channelName: string;
reset(): Channel;
// Radio.Commands
command(commandName: string, ...args: any[]): void;
comply(commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
comply(commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
complyOnce(commandName: string, callback: (...args: any[]) => void, context?: any): Commands;
complyOnce(commands: { [key: string]: (...args: any[]) => any }, context?: any): Commands;
stopComplying(commandName?: string, callback?: (...args: any[]) => void, context?: any): Commands;
// Radio.Requests
request(requestName: string, ...args: any[]): any;
reply(requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
reply(commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
replyOnce(requestName: string, callback: (...args: any[]) => any, context?: any): Requests;
replyOnce(commands: { [key: string]: (...args: any[]) => any }, context?: any): Requests;
stopReplying(commandName?: string, callback?: (...args: any[]) => any, context?: any): Requests;
}
}
}