Reactivity
Reactive primitives are introduced as needed through a clean and abstracted API. It currently leverages a customized version of the SolidJS Core, refactored to classes.
# Snippet
# Reactive Functions
| name | arguments | returns | description |
|---|---|---|---|
| signal | (initialValue, {equals:false/(a,b)=>a===b}) | [read, write, update] | {read:()=>value, write:(newValue)=>boolean, update:(prev)=>nextValue} | tuple to read and write values from/to a signal. Useupdate for running a function that receives the previous value and return to set a new value. When using update the signal doesnt track. |
| memo | fn | signal | read-only signal that will update when the return value of the function changes, memos are lazy |
| writable | fn | signal | like a memo but the function wont run unless is used (lazy), and if you write to the return value it will get that as a value |
| root | fn | dispose function | creates a new tracking scope |
| effect | fn | void | function to re-run when dependencies change |
| on | fn, fn | void | like effect but only the first function tracks |
| syncEffect | fn | void | function to re-run when dependencies change. the difference with an effect is that an effect may run at a later point in time while a syncEffect is garanteed to run right away after your call. |
| asyncEffect | (currentRunningEffect: Promise<any>) => any | any | for when you need to run effects one after another you can await the previous running effect with the parameter that the callback receives. |
| batch | fn | void | batches changes |
| cleanup | fn | void | cleanup callback for when the reactive context is disposed |
| owned | fn | owned function | returns a function that holds the owner on the scope. If you call it will run the function you passed initialy with that owner |
| withValue | withValue(value, fn) => fn(value) | void | given a value and a function, if the value is a function then it will create an effect that unwraps the value and pass it to the function you defined |
| map | map(Iterable, callback) | void | reactive version of array.map for iterables |