Evt.factorize(evt)
import { Evt, VoidEvt, matchVoid } from "evt";
declare evt: Evt<string> | Evt<number> | VoidEvt = Evt.create<any>();
evt.attach(data=> { }); // TS ERROR
Evt.factorize(evt) // OK, return Evt<string | number | void>
.attach(data=> { // data is string | number | void
//To test if data is void
if( matchVoid(data) ){
return;
}
//Here data is string | number.
})
;Last updated
Was this helpful?