Options
All
  • Public
  • Public/Protected
  • All
Menu

BoolCancelable is an IBoolCancelable class providing useful builders for cancelable references that can be queried for their canceled status.

Hierarchy

  • BoolCancelable

Implements

Index

Methods

cancel

  • cancel(): void

isCanceled

  • isCanceled(): boolean

Static alreadyCanceled

  • Returns a BoolCancelable reference that is already canceled.

    const ref = BoolCancelable.alreadyCanceled()
    
    ref.isCanceled()
    //=> true
    
    // Doesn't do anything, it's a no-op
    ref.cancel()
    

    The implementation returns the same reusable reference.

    Returns BoolCancelable

Static collection

  • Returns a BoolCancelable implementation that represents an immutable list of Cancelable references which can be canceled as a group.

    const list = BoolCancelable.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 BoolCancelable

Static empty

  • Returns a BoolCancelable implementation that doesn't do anything on cancel except for changing the status of isCanceled from false to true.

    const task = BoolCancelable.empty()
    
    task.isCanceled()
    //=> false
    
    task.cancel()
    task.isCanceled()
    //=> true
    

    Returns BoolCancelable

Static of

  • Lifts any callback into a BoolCancelable reference.

    const task = BoolCancelable.of(() => {
      console.log("I was canceled!")
    })
    
    task.isCanceled()
    //=> false
    
    task.cancel()
    //=> I was canceled!
    
    task.isCanceled()
    //=> true
    

    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 BoolCancelable

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