An effect is called once on construction and then again every time a recorded dependency has changed. Internally this is simply an observed ComputedSignal.

Implements

Constructors

Methods

Constructors

  • Creates an effect calling the given function once immediately and then again every time a recorded dependency has changed.

    Parameters

    • fn: EffectFunction

      The effect function to run. Can optionally return a cleanup function which is called before effect function is called again and on effect destruction.

    Returns Effect

Methods

  • Destroys the effect. This runs the cleanup function if returned by the last call of the effect function and then unsubscribes and destroys the internal computed signal.

    Returns void