Helper types

ToNonPostableEvt<E>

NonPostableEvt<T> and StatefulReadonlyEvt<T> are interfaces implemented respectively by the classes Evt<T> and StatefulEvt<T>. They contains all the methods but the ones used to post events, namely: .post(), .postOnceHandled() and the .state setter for StatefulReadonlyEvt

import { ToNonPostableEvt } from "evt";

ToNonPostableEvt<Evt<T>>         → NonPostableEvt<T>
ToNonPostableEvt<SatefulEvt<T>>  → StatefulReadonlyEvt<T>
ToNonPostable<VoidEvt>           → NonPostable<Void>
ToNonPostable<NonpostableEvt<T>> → NonPostableEvt<T>

ToNonPostableEvt<{ 
    evtText: Evt<string>; 
    evtCount: StatefulEvt<number>; 
    type: "FOO" 
}> 

{ 
    evtText: NonPostableEvt<string>; 
    evtCount: StatefulNonpostableEvt<number>; 
    type: "FOO"
}

Example use of the NonPostableEvt interface:

Run the example

ToPostableEvt<E>

Invert of ToNonPostableEvt

UnpackEvt<E>

Extract the type argument of an Evt

Example:

UnpackEvt is a helper type to infer the type argument of an Evt instance.

Run the example

SwapEvtType<E, T>

FactorizeEvt<E>

Last updated