on
Edit this pageSolid 2.0 —
The on helper has been removed in Solid 2.0. The split effect model makes it unnecessary — the compute function already serves as the explicit dependency declaration.
Replacement: split effects
The on helper was designed to make effect dependencies explicit. In Solid 2.0, the split effect model achieves this naturally:
// 1.x — using on() for explicit dependenciesimport { on, createEffect } from "solid-js"
createEffect(on(a, (v) => console.log(v, b())))
// 2.0 — compute function declares dependencies, apply runs the side effectcreateEffect( () => a(), // compute: explicitly track only `a` (v) => console.log(v, b()) // apply: `b` is not tracked)Deferred execution
The defer option that prevented the first run is no longer needed — effects in Solid 2.0 are already deferred by default (scheduled after the rendering phase).
Multiple dependencies
// 1.xcreateEffect(on([a, b], ([aVal, bVal]) => console.log(aVal, bVal)))
// 2.0createEffect( () => [a(), b()], ([aVal, bVal]) => console.log(aVal, bVal))