How to convert trigger/event into Promise or async/await?
Thanks to Bergi's comment I am able to convert it to Promise.
factoryMethod(msgIn, msgOut) {
return (ann) => new Promise((resolve, reject) => {
this.post(msgIn, ann);
$(window).on(msgOut, (e, arg) => resolve(arg));
});
}
This returns a higher order function that returns a Promise.