EVT
GitHubHomePlaygroud
v2
v2
  • 🚀EVT Overview
  • 📖API Documentation
    • Evt<T>
      • Async iterator
      • evt.attach*(...)
      • evt.post*(data)
      • evt.waitFor(...)
      • evt.evt[Attach|Detach]
      • evt.pipe(...)
      • evt.getHandlers()
      • evt.isHandled(data)
      • evt.detach(ctx?)
      • evt.enableTrace(...)
      • evt.setMaxHandlers(n)
      • toStateful(initialState)
      • evt.getStatelessOp(op)
      • Evt.create(initalState?)
      • Evt.newCtx<T>()
      • Evt.getCtx(object)
      • Evt.from<T>(...)
      • Evt.merge([ evt1, evt2, ... ])
      • Evt.loosenType(evt)
      • Evt.factorize(evt)
      • Evt.asPostable(evt)
      • Evt.asNonPostable(evt)
      • Evt.setDefaultMaxHandlers(n)
    • Ctx<T>
    • Operator<T, U> (type)
    • StatefulEvt<T>
    • Helper types
    • Handler<T, U> (type)
  • 🪝React hooks
  • 🔩From EventEmitter to Evt
  • ⬆️v1 -> v2
Powered by GitBook
On this page
  • Return
  • Parameters
  • Example
Edit on GitHub
  1. API Documentation
  2. Evt<T>

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

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]);

evtTextOrTime.attach(console.log);

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

ctx.done();

evtText.post("Foo bar"); //Prints nothing
PreviousEvt.from<T>(...)NextEvt.loosenType(evt)

Last updated 2 years ago

📖
Run the example