Returns a new SerialCancelable that's empty.
Initiates an SerialCancelable reference and assigns it
a reference that wraps the given cb
callback.
So this code:
SerialCancelable.of(() => console.log("cancelled"))
Is equivalent to this:
const ref = SerialCancelable.empty()
ref.update(Cancelable.of(() => console.log("cancelled")))
Generated using TypeDoc
The
SerialCancelable
is an IAssignCancelable whose underlying cancelable reference can be swapped for another and on each swap the previous reference gets canceled.Example:
const ref = SerialCancelable() ref.update(c1) // sets the underlying cancelable to c1 ref.update(c2) // cancels c1, swaps the underlying cancelable to c2 ref.cancel() // also cancels c2 ref := c3 // also cancels c3, because s is already canceled
Also see SerialCancelable, which is similar, except that it cancels the old cancelable upon assigning a new cancelable.