Evt.asPostable(evt)
Cast the passed event as portable.
Deprecated
Evt.asPostable() will be removed in the next major of Evt.
If you are currently using it, consider refactoring your code so that you don't need it anymore.
See this newer example. ( that replace the older one).
import { Evt } from "evt";
import type {
NonPostableEvt,
+ ToPostableEvt
} from "evt";
const evtMsg: NonPostableEvt<string> = new Evt();
-Evt.toPostable(evtMsg).post("foo");
+(evtMsg as ToPostable<typeof evtMsg>).post("foo");Usecase
Use this method only onEvt you instantiated yourself. Not as a hack to trigger events on Evt that have been exposed as non-postable by an API.
To invoke post() on a NonPostableEvt or a StatefullReadonlyEvt.
Without this method this would be the way for a class to expose Evt that are posted internally and exposed to be listened.
Now it can be frustrating to have to store a private property only to call post on a object that we know is postable. Here is were this method come in handy:
Last updated