evt.waitFor(...)
Method that returns a promise that will resolve when the next matched event is posted.
Without timeout
By default the promise returned by waitFor will never reject.
import { Evt } from "evt";
const evtText = Evt.create<string>();
setTimeout(()=> evtText.post("Hi!"), 1500);
(async ()=>{
//waitFor return a promise that will resolve next time
//post() is invoked on evtText.
const text = await evtText.waitFor();
console.log(text);
})();With timeout
As with attach*, it is possible to set what is the maximum amount of time we are willing to wait for the event before the promise rejects.
Subtilities of evt.waitFor(...)
evt.waitFor(...) Last updated