Function createSignalScope

  • Creates an effect scope that groups multiple reactive effects for lifecycle management.

    Type Parameters

    • T

      The return type of the callback.

    Parameters

    • callback: () => T

      A function where effects can be created. All effects created within will be scoped.

    Returns () => void

    A stop function to cancel all effects within the scope.

    const stopScope = createSignalScope(() => {
    createEffect(() => {
    console.log('Scoped effect');
    });
    });

    // Later, stop all scoped effects:
    stopScope();