Creates executors and manages their lifecycle.

Hierarchy (view full)

Implements

Constructors

Properties

_executors: Map<unknown, ExecutorImpl<any>> = ...

The map from a key to an executor.

_initialState: Map<unknown, ExecutorState<any>> = ...

The map from a key to an initial state that must be set to an executor before plugins are applied. Entries from this map are deleted after the executor is initialized.

_keySerializer: undefined | ((key) => unknown)

Serializes executor keys.

Type declaration

    • (key): unknown
    • Parameters

      • key: unknown

      Returns unknown

_plugins: ExecutorPlugin[] = []

Plugins that are applied to all executors.

_pubSub: PubSub<ExecutorEvent<any>> = ...

The pubsub that handles the manager subscriptions.

Methods

  • Iterates over executors created by the manager.

    Returns IterableIterator<Executor<any>>

  • Converts a key into its serialized form.

    Parameters

    • key: unknown

      The key to convert.

    Returns unknown

    The serialized key.

  • Deletes the non-active executor from the manager.

    If the detached executor is pending then it is not aborted. Subscribe to the detach event on either manager or an executor and abort it manually.

    Parameters

    • key: unknown

      The key of the executor to delete.

    Returns boolean

    true if the executor was detached, or false if there's no such executor, or the executor is active.

  • Returns an executor by its key, or undefined if there's no such executor.

    Parameters

    • key: unknown

      The unique executor key.

    Returns undefined | Executor<any>

  • Returns an existing executor or creates a new one.

    Type Parameters

    • Value = any

    Parameters

    • key: unknown

      The unique executor key.

    • initialValue: undefined

      The initial executor value.

    • Optional plugins: (undefined | null | ExecutorPlugin<Value>)[]

      The array of plugins that are applied to the newly created executor.

    Returns Executor<Value>

  • Returns an existing executor or creates a new one.

    Type Parameters

    • Value = any

    Parameters

    • key: unknown

      The unique executor key.

    • Optional initialValue: Value | ExecutorTask<Value> | PromiseLike<Value>

      The initial executor value.

    • Optional plugins: (undefined | null | ExecutorPlugin<NoInfer<Value>>)[]

      The array of plugins that are applied to the newly created executor.

    Returns Executor<Value>

  • Injects the initial state for the executor that is created in the future.

    Parameters

    Returns boolean

    true if the executor was hydrated, or false if the executor already exists and cannot be hydrated.

  • Subscribes a listener to the events published by all executors that are created by this manager.

    Parameters

    • listener: ((event) => void)

      The listener to subscribe.

    Returns (() => void)

    The callback that unsubscribes the listener.

      • (): void
      • Returns void