• transforms a regular equality check function (SimpleSignalConfig.equals) into a one that throttles when called too frequently.
    this means that a signal composed of this as its equals function will limit propagating itself further, until at least delta_time_ms amount of time has passed since the last time it was potentially propagated.

    Type Parameters

    • T

    Parameters

    • delta_time_ms: number

      the time interval in milliseconds for throttling

    • Optional base_equals: EqualityCheck<T>

      use an optional customized equality checking function. otherwise the default prev_value === new_value comparison will be used

    Returns EqualityCheck<T>

    a throttled version of the equality checking function which would prematurely return a true if called too frequently (ie within delta_time_ms interval since the last actual equality checking)

    Example

    const { createState, createMemo, createEffect } = createContext()
    const [A, setA] = createState(0)
    const B = createMemo((id) => {
    return A(id) ** 0.5
    }, { equals: throttlingEquals(500) }) // at least 500ms must pass before `B` propagates itself onto `C`
    const [C, fireC] = createEffect((id) => {
    // SOME EXPENSIVE COMPUTATION OR EFFECT //
    console.log("C says Hi!, and B is of the value:", B(id))
    }, { defer: false })
    // it is important that you note that `B` will be recomputed each time `setA(...)` is fired.
    // it is only that `B` won't propagate to `C` (even if it changes in value) if at least 500ms have not passed
    setInterval(() => setA(A() + 1), 10)

Generated using TypeDoc