Sets the underlying cancelable reference to undefined
,
useful for garbage-collecting purposes.
In case the underlying reference is also a MultiAssignCancelable
, then
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()
Return true
in case this cancelable hasn't been canceled,
or false
otherwise.
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 value
is
going to be canceled on assignment as well.
Returns a new MultiAssignCancelable that's empty.
Initiates an MultiAssignCancelable reference and assigns it
a reference that wraps the given cb
callback.
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
The
MultiAssignCancelable
is an IAssignCancelable whose underlying cancelable reference can be swapped for another.Example:
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.