Update 14_create_effect.md

This commit is contained in:
Greg Johnston
2025-01-30 09:43:01 -05:00
committed by GitHub
parent 7b7260e1fb
commit bf566af128

View File

@@ -126,7 +126,7 @@ Every time `count` is updated, this effect will rerun. This is what allows react
In addition to `Effect::new()`, Leptos provides an [`Effect::watch()`](https://docs.rs/leptos/latest/leptos/reactive/effect/struct.Effect.html#method.watch) function, which can be used to separate tracking and responding to changes by explicitly passing in a set of values to track.
`watch` takes three arguments. The `deps` argument is reactively tracked while `callback` and `immediate` are not. Whenever `deps` is changed, `callback` is run. If `immedidate` is false, the callback will run only after the first change is detected of any signal that is accessed in deps. `watch` returns an `Effect`, which can be called with `.stop()` to stop tracking the dependencies.
`watch` takes three arguments. The `deps` argument is reactively tracked while `callback` and `immediate` are not. Whenever `deps` is changed, `callback` is run. If `immediate` is false, the callback will run only after the first change is detected of any signal that is accessed in deps. `watch` returns an `Effect`, which can be called with `.stop()` to stop tracking the dependencies.
```rust
let (num, set_num) = signal(0);