durable-execution - v0.8.0
    Preparing search index...

    Type Alias CancelSignal

    A cancel signal is similar to an AbortSignal. It allows you to check for cancellation and register a callback that will be called when the signal is cancelled.

    async function doSomething() {
    const onCancel = () => {
    throw new DurableTaskCancelledError()
    }
    cancelSignal.onCancelled(onCancel)

    try {
    ...doWork()
    } finally {
    cancelSignal.clearOnCancelled(onCancel)
    }
    }
    type CancelSignal = {
        onCancelled: (fn: () => void) => void;
        clearOnCancelled: (fn: () => void) => void;
        isCancelled: () => boolean;
    }
    Index

    Properties

    onCancelled: (fn: () => void) => void

    Register a callback that will be called when the signal is cancelled.

    Type declaration

      • (fn: () => void): void
      • Parameters

        • fn: () => void

          The callback to register.

        Returns void

    clearOnCancelled: (fn: () => void) => void

    Clear a callback that was registered with onCancelled.

    Type declaration

      • (fn: () => void): void
      • Parameters

        • fn: () => void

          The callback to clear. Should be the same function that was registered with onCancelled.

        Returns void

    isCancelled: () => boolean

    Check if the signal is cancelled.

    Type declaration

      • (): boolean
      • Returns boolean

        true if the signal is cancelled, false otherwise.