1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | /**
|
7 | * A Dispatcher is a utility that manager event listeners registered for events
|
8 | * and allows distributing (firing) events to the listeners registered for the
|
9 | * given event.
|
10 | *
|
11 | * The dispatcher provides a single-node event bus and is usually used to
|
12 | * propagate events from controllers to UI components when modifying/passing
|
13 | * the state is impractical for any reason.
|
14 | *
|
15 | * @interface
|
16 | */
|
17 | class Dispatcher {
|
18 | /**
|
19 | * Deregisters all event listeners currently registered with this
|
20 | * dispatcher.
|
21 | *
|
22 | * @return {Dispatcher} This dispatcher.
|
23 | */
|
24 | clear() {}
|
25 |
|
26 | /**
|
27 | * Registers the provided event listener to be executed when the specified
|
28 | * event is fired on this dispatcher.
|
29 | *
|
30 | * When the specified event is fired, the event listener will be executed
|
31 | * with the data passed with the event as the first argument.
|
32 | *
|
33 | * The order in which the event listeners will be executed is unspecified
|
34 | * and should not be relied upon. Registering the same listener for the
|
35 | * same event and with the same scope multiple times has no effect.
|
36 | *
|
37 | * @param {string} event The name of the event to listen for.
|
38 | * @param {function(*)} listener The event listener to register.
|
39 | * @param {?Object=} scope The object to which the {@code this} keyword
|
40 | * will be bound in the event listener.
|
41 | * @return {Dispatcher} This dispatcher.
|
42 | */
|
43 | listen() {}
|
44 |
|
45 | /**
|
46 | * Deregisters the provided event listener, so it will no longer be
|
47 | * executed with the specified scope when the specified event is fired.
|
48 | *
|
49 | * @param {string} event The name of the event for which the listener
|
50 | * should be deregistered.
|
51 | * @param {function(*)} listener The event listener to deregister.
|
52 | * @param {?Object=} scope The object to which the {@code this} keyword
|
53 | * would be bound in the event listener.
|
54 | * @return {Dispatcher} This dispatcher.
|
55 | */
|
56 | unlisten() {}
|
57 |
|
58 | /**
|
59 | * Fires a new event of the specified name, carrying the provided data.
|
60 | *
|
61 | * The method will synchronously execute all event listeners registered for
|
62 | * the specified event, passing the provided data to them as the first
|
63 | * argument.
|
64 | *
|
65 | * Note that this method does not prevent the event listeners to modify the
|
66 | * data in any way. The order in which the event listeners will be executed
|
67 | * is unspecified and should not be relied upon.
|
68 | *
|
69 | * @param {string} event The name of the event to fire.
|
70 | * @param {Object<string, *>} data The data to pass to the event listeners.
|
71 | * @param {boolean=} [imaInternalEvent=false] The flag signalling whether
|
72 | * this is an internal IMA event. The fired event is treated as a
|
73 | * custom application event if this flag is not set.
|
74 | * The flag is used only for debugging and has no effect on the
|
75 | * propagation of the event.
|
76 | * @return {Dispatcher} This dispatcher.
|
77 | */
|
78 | fire() {}
|
79 | }
|
80 | exports.default = Dispatcher;
|
81 |
|
82 | typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/event/Dispatcher', [], function (_export, _context) {
|
83 | ;
|
84 | return {
|
85 | setters: [],
|
86 | execute: function () {
|
87 | _export('default', exports.default);
|
88 | }
|
89 | };
|
90 | });
|