Effect API
Reference for reactive side effects and disposal.
This page lists the supported API for the Effect module.
Effect
Effect runs side effects when the signals it reads change.
Effect.disposer
1type disposer = {dispose: unit => unit}
A manual teardown handle returned by Effect.runWithDisposer.
Effect.run
1let run: (2 unit => option<unit => unit>,3 ~name: option<string>=?,4) => unit
Run an effect immediately, then re-run it whenever tracked dependencies change. Return Some(cleanup) to clean up before the next run, or None when no cleanup is needed.
Effect.runWithDisposer
1let runWithDisposer: (2 unit => option<unit => unit>,3 ~name: option<string>=?,4) => Effect.disposer
Run an effect and return a disposer for explicit teardown.
Example
1open Xote23let count = Signal.make(0)45let disposer = Effect.runWithDisposer(() => {6 Console.log2("count", Signal.get(count))7 None8})910disposer.dispose()