EVT
Search…
Evt.merge([ evt1, evt2, ... ])
Returns a new Evt instance which concurrently post all event data from every given input Evt.

Return

A new Evt that has for type arguments the union of the type arguments of the inputs Evt.

Parameters

Ctx<any> Optional, Ctx that will be used to detach the handler that has been attached to the input Evts.
Evt<any>[] Evts to be merged.

Example

1
import { Evt } from "evt";
2
3
const ctx= Evt.newCtx();
4
5
const evtText = new Evt<string>();
6
const evtTime = new Evt<number>();
7
8
//evtTextOrTime is Evt<string | number>, ctx is optional.
9
const evtTextOrTime= Evt.merge(ctx, [evtText, evtTime]);
10
11
evtTextOrTime.attach(console.log);
12
13
evtText.post("Foo bar"); //Prints "Foo bar"
14
15
ctx.done();
16
17
evtText.post("Foo bar"); //Prints nothing
Copied!
Last modified 1yr ago
Copy link