mirror of
https://github.com/centau/vide.git
synced 2026-08-21 15:41:38 +00:00
Update docs
This commit is contained in:
parent
9b6be14441
commit
46937c6979
16 changed files with 157 additions and 116 deletions
|
|
@ -60,17 +60,15 @@ effect(function()
|
|||
end)
|
||||
|
||||
effect(function()
|
||||
text() -- does not print
|
||||
text() -- does not print, returns cached value
|
||||
end)
|
||||
```
|
||||
|
||||
Deriving a source in this manner is similar to creating an effect to update
|
||||
another source. You should never manually do this using an effect however,
|
||||
improper usage could accidently create infinite loops in the reactive graph.
|
||||
Always favour deriving when you need one source to update based on another.
|
||||
|
||||
`derive()` must also be used within a root reactive scope, just like `effect()`.
|
||||
|
||||
If the recalculated value is the same as the old value, the derived source will
|
||||
not rerun the effects using it.
|
||||
|
||||
The reactive graph for the above example:
|
||||
|
||||
```mermaid
|
||||
|
|
@ -86,10 +84,15 @@ The reactive graph for the above example:
|
|||
}
|
||||
}}%%
|
||||
|
||||
flowchart
|
||||
graph
|
||||
|
||||
subgraph root
|
||||
direction LR
|
||||
count --> text --> effect1 & effect2
|
||||
end
|
||||
```
|
||||
|
||||
Deriving a source in this manner is similar to creating an effect to update
|
||||
another source. You should never manually do this using an effect however,
|
||||
improper usage could accidently create infinite loops in the reactive graph.
|
||||
Always favour deriving when you need one source to update based on another.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue