• Creates an async iterator for a signal.

    Type Parameters

    • T

    Parameters

    • source: Signal<T>

      The signal to create an async iterator for.

    • Optionaloptions: SignalToIteratorOptions

      Options for the signal.

    Returns Required<AsyncIterableIterator<T>>

    // assumes this is within a component
    readonly source = signal('initial');
    constructor() {
    for await (const item of signalToIterator(this.source)) {
    console.log(item); // 'initial', 'next';
    }
    this.source.set('next');
    }