Documentation
    Preparing search index...

    Interface StatefulSubjectController<Actions>

    A ControllableStream is ReadableStream that can have chunks queued to from an external source.

    Queuing items externally.

    const controller = new ControllableStream<number>()
    controller.enqueue(1)
    controller.enqueue(2)
    controller.enqueue(3)
    controller.close()

    Registering pull subscribers externally.

    const controller = new ControllableStream<number>()
    let i = -1
    controller.onPull(() => ++i)
    interface StatefulSubjectController<Actions extends Record<string, unknown>> {
        locked: boolean;
        get desiredSize(): number | null;
        "[asyncIterator]"(
            options?: ReadableStreamIteratorOptions,
        ): ReadableStreamAsyncIterator<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >;
        cancel(reason?: any): Promise<void>;
        close(): void;
        dispatch<Action extends string | number | symbol>(
            action: Action,
            param?: Actions[Action],
        ): void;
        enqueue(chunk: AccumulateStateReducerInput): void;
        error(error?: unknown): void;
        getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
        getReader(): ReadableStreamDefaultReader<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >;
        getReader(
            options?: ReadableStreamGetReaderOptions,
        ): ReadableStreamReader<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >;
        onPull(
            pullListener: ControllerPullListener<
                AccumulateStateReducerInput<
                    Actions,
                    ListOf<keyof Actions>,
                    { action: "__INIT__"; param: void },
                >,
            >,
        ): () => void;
        pipeThrough<T>(
            transform: ReadableWritablePair<
                T,
                AccumulateStateReducerInput<
                    Actions,
                    ListOf<keyof Actions>,
                    { action: "__INIT__"; param: void },
                >,
            >,
            options?: StreamPipeOptions,
        ): ReadableStream<T>;
        pipeTo(
            destination: WritableStream<
                AccumulateStateReducerInput<
                    Actions,
                    ListOf<keyof Actions>,
                    { action: "__INIT__"; param: void },
                >,
            >,
            options?: StreamPipeOptions,
        ): Promise<void>;
        tee(): [
            ReadableStream<
                AccumulateStateReducerInput<
                    Actions,
                    ListOf<keyof Actions>,
                    { action: "__INIT__"; param: void },
                >,
            >,
            ReadableStream<
                AccumulateStateReducerInput<
                    Actions,
                    ListOf<keyof Actions>,
                    { action: "__INIT__"; param: void },
                >,
            >,
        ];
        values(
            options?: ReadableStreamIteratorOptions,
        ): ReadableStreamAsyncIterator<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >;
    }

    Type Parameters

    • Actions extends Record<string, unknown>

    Hierarchy (View Summary)

    Index

    Properties

    locked: boolean

    Accessors

    Methods

    • Parameters

      • Optionaloptions: ReadableStreamIteratorOptions

      Returns ReadableStreamAsyncIterator<
          AccumulateStateReducerInput<
              Actions,
              ListOf<keyof Actions>,
              { action: "__INIT__"; param: void },
          >,
      >

    • Parameters

      • Optionalreason: any

      Returns Promise<void>

    • Parameters

      • options: { mode: "byob" }

      Returns ReadableStreamBYOBReader

    • Returns ReadableStreamDefaultReader<
          AccumulateStateReducerInput<
              Actions,
              ListOf<keyof Actions>,
              { action: "__INIT__"; param: void },
          >,
      >

    • Parameters

      • Optionaloptions: ReadableStreamGetReaderOptions

      Returns ReadableStreamReader<
          AccumulateStateReducerInput<
              Actions,
              ListOf<keyof Actions>,
              { action: "__INIT__"; param: void },
          >,
      >

    • Register a pull subscriber.

      Parameters

      • pullListener: ControllerPullListener<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >

      Returns () => void

      When the stream is ready to pull it will pull from all subscribers until the desired size has been fulfilled.

    • Type Parameters

      • T

      Parameters

      • transform: ReadableWritablePair<
            T,
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >
      • Optionaloptions: StreamPipeOptions

      Returns ReadableStream<T>

    • Parameters

      • destination: WritableStream<
            AccumulateStateReducerInput<
                Actions,
                ListOf<keyof Actions>,
                { action: "__INIT__"; param: void },
            >,
        >
      • Optionaloptions: StreamPipeOptions

      Returns Promise<void>

    • Returns [
          ReadableStream<
              AccumulateStateReducerInput<
                  Actions,
                  ListOf<keyof Actions>,
                  { action: "__INIT__"; param: void },
              >,
          >,
          ReadableStream<
              AccumulateStateReducerInput<
                  Actions,
                  ListOf<keyof Actions>,
                  { action: "__INIT__"; param: void },
              >,
          >,
      ]

    • Parameters

      • Optionaloptions: ReadableStreamIteratorOptions

      Returns ReadableStreamAsyncIterator<
          AccumulateStateReducerInput<
              Actions,
              ListOf<keyof Actions>,
              { action: "__INIT__"; param: void },
          >,
      >