> > Since checking `promise.state` is synchronous, we may as well just > write a synchronous Cancel class instead: >
Right - see upthread. You do need some kind of callback method, though, like `whenCancelled(callback)`. > class Cancel { > constructor() { this.requested = false } > request() { this.requested = true } > throw() { throw new CancelError() } > } > We need to separate the capability to "read" the cancellation request from the ability to request the cancellation. That's why in .NET you have CancellationTokenSource and CancellationToken. But for JS, we should probably use the revealing constructor pattern instead (discussed upthread): let token = new CancelToken(cancel => { ... });
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss