1 | declare module '@ember/object/evented' {
|
2 | import Mixin from '@ember/object/mixin';
|
3 | export { on } from '@ember/-internals/metal';
|
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 | interface Evented {
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | on<Target>(
|
70 | name: string,
|
71 | target: Target,
|
72 | method: string | ((this: Target, ...args: any[]) => void)
|
73 | ): this;
|
74 | on(name: string, method: ((...args: any[]) => void) | string): this;
|
75 | /**
|
76 | Subscribes a function to a named event and then cancels the subscription
|
77 | after the first time the event is triggered. It is good to use ``one`` when
|
78 | you only care about the first time an event has taken place.
|
79 |
|
80 | This function takes an optional 2nd argument that will become the "this"
|
81 | value for the callback. When the target parameter is used the callback method
|
82 | becomes the third argument.
|
83 |
|
84 | @method one
|
85 | @param {String} name The name of the event
|
86 | @param {Object} [target] The "this" binding for the callback
|
87 | @param {Function|String} method A function or the name of a function to be called on `target`
|
88 | @return this
|
89 | @public
|
90 | */
|
91 | one<Target>(
|
92 | name: string,
|
93 | target: Target,
|
94 | method: string | ((this: Target, ...args: any[]) => void)
|
95 | ): this;
|
96 | one(name: string, method: string | ((...args: any[]) => void)): this;
|
97 | /**
|
98 | Triggers a named event for the object. Any additional arguments
|
99 | will be passed as parameters to the functions that are subscribed to the
|
100 | event.
|
101 |
|
102 | ```javascript
|
103 | person.on('didEat', function(food) {
|
104 | console.log('person ate some ' + food);
|
105 | });
|
106 |
|
107 | person.trigger('didEat', 'broccoli');
|
108 |
|
109 | // outputs: person ate some broccoli
|
110 | ```
|
111 |
|
112 | @method trigger
|
113 | @param {String} name The name of the event
|
114 | @param {Object...} args Optional arguments to pass on
|
115 | @public
|
116 | */
|
117 | trigger(name: string, ...args: any[]): any;
|
118 | /**
|
119 | Cancels subscription for given name, target, and method.
|
120 |
|
121 | @method off
|
122 | @param {String} name The name of the event
|
123 | @param {Object} target The target of the subscription
|
124 | @param {Function|String} method The function or the name of a function of the subscription
|
125 | @return this
|
126 | @public
|
127 | */
|
128 | off<Target>(
|
129 | name: string,
|
130 | target: Target,
|
131 | method: string | ((this: Target, ...args: any[]) => void)
|
132 | ): this;
|
133 | off(name: string, method: string | ((...args: any[]) => void)): this;
|
134 | /**
|
135 | Checks to see if object has any subscriptions for named event.
|
136 |
|
137 | @method has
|
138 | @param {String} name The name of the event
|
139 | @return {Boolean} does the object have a subscription for event
|
140 | @public
|
141 | */
|
142 | has(name: string): boolean;
|
143 | }
|
144 | const Evented: Mixin;
|
145 | export default Evented;
|
146 | }
|
147 |
|
\ | No newline at end of file |