> My questions is, how can we setup a function to abort a pending async 
> function?


That's an interesting question. Cancellation of promises is something
that has been debated several times (not sure if at all in esdiscuss).
There is a specification but there are many objections to it and some
think it complects promises. Domenic is probably up to date on this.


In your case you have several alternatives with the current API:

 - You can return a rejected promise whenever a `client` method gets
invoked if it is in error state.

 - You can use promises directly rather than an async function which
would probably give you finer grained control here.

 - You can pass a token into clients' methods ala c#'s
CancellationToken and invoke it on errors to signal something bad
happened from the outside.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to