EVT
Search…
Handler<T, U> (type)
Every time attach*, waitFor or pipe is invoked a new Handler<T, U> is attached to the Evt<T>.
Handlers can be listed using the evt.getHandler() method.
1
type Handler<T,U> = {
2
3
//Method for detaching the handler from the Evt, returns false if
4
//if invoked when the handler is no longer attached.
5
detach(): boolean;
6
7
//The promise returned by the attach*() and waitFor() method.
8
promise: Promise<U>;
9
10
11
/* Properties that depends on the method used to attach the handler */
12
13
//true if the handler was attached using a method containing "prepend"
14
//in it's name. Example: evt.$attachOncePrepend(...)
15
prepend: boolean;
16
17
//... if the method contained "extract"
18
extract: boolean;
19
20
//... if the method contained "once"
21
once: boolean;
22
23
//if the method was waitFor()
24
async: boolean;
25
26
27
28
/* Properties passed as argument to the method used to attach the handler */
29
30
//Default: ()=> true, a filter that matches all events.
31
op: Operator<T,U>;
32
33
//Default: undefined
34
ctx?: Ctx;
35
36
//Default: undefined.
37
timeout?: number;
38
39
//Undefined only when the handler was attached using evt.waitFor()
40
callback?: (transformedData: U)=> void;
41
42
};
Copied!

Glossary relative to handers:

  • An event is said to be matched by a handler if posting it causes the callback to be invoked. In practice this is the case when the handler's operator returns true or [ value, ].
  • An event is said to be handled by a handler if the event data is matched or if posting it causes the handler and/or other potential handlers to be detached. In practice this is the case when the handler's operator returns "DETACH" or {DETACH: Ctx}. It is possible to test if a given event data is handled by at least one of the handlers attached to an Evt<T> by using the evt.isHandled(data) method.