Function observe

  • Reactively run a function, meaning the function will rerun when any Store that was read during its execution is updated. Calls to observe can be nested, such that changes to Stores read by the inner function do no cause the outer function to rerun.

    Example

    let number = new Store(0)
    let doubled = new Store()
    setInterval(() => number.set(0|Math.random()*100)), 1000)

    observe(() => {
    doubled.set(number.get() * 2)
    })

    observe(() => {
    console.log(doubled.get())
    })

    Parameters

    • func: (() => void)

      The function to be (repeatedly) executed.

        • (): void
        • Returns void

    Returns void

Generated using TypeDoc