Evt.merge([ evt1, evt2, ... ])

Returns a new Evt instance which concurrently post all event data from every given input Evt.


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


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.


import { Evt } from "evt";

const ctx= Evt.newCtx();

const evtText = new Evt<string>();
const evtTime = new Evt<number>();

//evtTextOrTime is Evt<string | number>, ctx is optional.
const evtTextOrTime= Evt.merge(ctx, [evtText, evtTime]);


evtText.post("Foo bar"); //Prints "Foo bar"


evtText.post("Foo bar"); //Prints nothing

Run the example

Last updated