Class PipeableSSRExecutorManager

Streaming executor manager for NodeJS environment.

Hierarchy (view full)

Constructors

Properties

_executorFilter: ((executor) => boolean)

Filters executors that must be hydrated on the client with the state that was accumulated during SSR.

Type declaration

    • (executor): boolean
    • Parameters

      Returns boolean

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

The map from a key to an executor.

_hydratedVersions: WeakMap<Executor<any>, number> = ...

Map from an executor to a version of the state that was sent to the client for hydration.

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

_plugins: ExecutorPlugin[] = []

Plugins that are applied to all executors.

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

The pubsub that handles the manager subscriptions.

_stateStringifier: {
    (value, replacer?, space?): string;
    (value, replacer?, space?): string;
}

Stringifies the state of the executor before sending it to the client.

Type declaration

    • (value, replacer?, space?): string
    • Parameters

      • value: any
      • Optional replacer: ((this, key, value) => any)
          • (this, key, value): any
          • Parameters

            • this: any
            • key: string
            • value: any

            Returns any

      • Optional space: string | number

      Returns string

    • (value, replacer?, space?): string
    • Parameters

      • value: any
      • Optional replacer: null | (string | number)[]
      • Optional space: string | number

      Returns string

keySerializer: ((key) => unknown)

Serializes keys of executors.

Type declaration

    • (key): unknown
    • Parameters

      • key: unknown

      Returns unknown

nonce: undefined | string

A nonce string to allow scripts for script-src Content-Security-Policy.

stream: WritableStream

The stream that includes both React rendering chunks and executor hydration chunks.

Methods

  • Instantly aborts all pending executors and preserves their available results as is.

    Parameters

    • Optional reason: unknown

      The abort reason that is used for rejection of the pending task promises.

    Returns void

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

  • Resolves with true if there were pending executors and their state has changed after they became non-pending. Otherwise, resolves with false.

    Returns Promise<boolean>

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

  • Returns an inline <script> tag with source that hydrates the client with the state accumulated during SSR, or an empty string if there are no state changes since the last time nextHydrationScript was called.

    Returns string

  • Returns a script source that hydrates the client with the state accumulated during SSR, or an empty string if there are no state changes since the last time nextHydrationScript was called.

    Returns string

  • 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