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
Edit on GitHub
  1. API Documentation

Handler<T, U> (type)

PreviousHelper typesNextReact hooks

Last updated 2 years ago

Every time , or is invoked a new is attached to the .

Handlers can be listed using the method.

type Handler<T,U> = {

    //Method for detaching the handler from the Evt, returns false if 
    //if invoked when the handler is no longer attached.
    detach(): boolean;

    //The promise returned by the attach*() and waitFor() method.
    promise: Promise<U>;


    /* Properties that depends on the method used to attach the handler */

    //true if the handler was attached using a method containing "prepend"
    //in it's name. Example: evt.$attachOncePrepend(...)
    prepend: boolean;

    //... if the method contained "extract"
    extract: boolean;

    //... if the method contained "once"
    once: boolean;

    //if the method was waitFor()
    async: boolean;



    /* Properties passed as argument to the method used to attach the handler */

    //Default: ()=> true, a filter that matches all events.
    op: Operator<T,U>; 

    //Default: undefined
    ctx?: Ctx; 

    //Default: undefined.
    timeout?: number;

    //Undefined only when the handler was attached using evt.waitFor()
    callback?: (transformedData: U)=> void;

};

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 method.

📖
attach*
waitFor
pipe
Handler<T, U>
Evt<T>
evt.getHandler()
evt.isHandled(data)