Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • MultiAssignCancelable

Implements

Index

Constructors

constructor

Methods

cancel

  • cancel(): void

clear

  • clear(): this
  • Sets the underlying cancelable reference to undefined, useful for garbage-collecting purposes.

    Returns this

collapse

  • collapse(): this
  • 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()
    

    Returns this

isCanceled

  • isCanceled(): boolean
  • 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
    

    Returns boolean

update

  • 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.

    Parameters

    Returns this

Static empty

Static of

  • 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")))
    

    Parameters

    • cb: function
        • (): void
        • Returns void

    Returns MultiAssignCancelable

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc