Utility that cancels a list of cancelable references, delaying any thrown exceptions until all references have been cancelled.
In case multiple exceptions are caught, then the thrown exception
is going to be a CompositeError
.
Returns a Cancelable implementation that represents an immutable list of Cancelable references which can be canceled as a group.
const list = Cancelable.collection(
Cancelable.of(() => console.log("Cancelled #1")),
Cancelable.of(() => console.log("Cancelled #2")),
Cancelable.of(() => console.log("Cancelled #3"))
)
list.cancel()
//=> Cancelled #1
//=> Cancelled #2
//=> Cancelled #3
is the array of references to cancel when cancellation is triggered
Returns a reusable Cancelable
reference that doesn't
do anything on cancel
.
Lifts any callback into a Cancelable
reference.
const task = Cancelable.of(() => {
console.log("I was canceled!")
})
task.cancel()
//=> I was canceled!
The returned reference has guaranteed idempotence, so calling it multiple times will trigger the given callback only once.
Generated using TypeDoc
Cancelable
is an ICancelable class providing useful builders for simple cancelable references.