MultiAssignCancelable is an IAssignCancelable whose
underlying cancelable reference can be swapped for another.
const ref = MultiAssignCancelable() ref.update(c1) // sets the underlying cancelable to c1 ref.update(c2) // 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.
Sets the underlying cancelable reference to
useful for garbage-collecting purposes.
In case the underlying reference is also a
collapse its state into this one.
const c = Cancelable.of(() => console.info("Cancelled!")) const mc1 = new MultiAssignCancelable() mc1.update(c) const mc2 = new MultiAssignCancelable() mc2.update(mc1) // After this the underlying reference of `mc2` becomes `c` mc2.collapse()
true in case this cancelable hasn't been canceled,
const ref = BoolCancelable.of() ref.isCanceled() // false ref.cancel() ref.isCanceled() // true
Updates the internal reference of this assignable cancelable to the given value.
If this cancelable is already canceled, then
going to be canceled on assignment as well.
Initiates an MultiAssignCancelable reference and assigns it
a reference that wraps the given
So this code:
MultiAssignCancelable.of(() => console.log("cancelled"))
Is equivalent to this:
const ref = MultiAssignCancelable.empty() ref.update(Cancelable.of(() => console.log("cancelled")))
Generated using TypeDoc