Options
All
  • Public
  • Public/Protected
  • All
Menu

Cancelable is an ICancelable class providing useful builders for simple cancelable references.

Hierarchy

  • Cancelable

Implements

Index

Methods

Abstract cancel

  • cancel(): void

Static cancelAll

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

    Parameters

    Returns void

Static collection

  • 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
    

    Parameters

    • Rest ...refs: Array<ICancelable>

      is the array of references to cancel when cancellation is triggered

    Returns Cancelable

Static empty

Static of

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

    Parameters

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

    Returns Cancelable

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