v0.14.134 - 53.2 / 50.3

Reactivity

Reactive Primitives are added out of necessity in a sensible and abstracted API. Currently it uses a customized port to Classes of the Solid Core Reactivity.

# Snippet

# Reactive Functions

nameargumentsreturnsdescription
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.
signalify(object, [prop1, props2]?)objectit replaces already exsisting object properties with setters/getters. It can be used in a class with getters/setters. Aditionally you may pass an array of prop names to choose what to signalify. NOTE: new properties wont be tracked/mutable. This is NOT recursive.
mutableobjectobjectit replaces all object properties with setters/getters. New properties are tracked/mutable. This is done recursively.
merge(target, source, keys?)targetMerge `source` into `target`
replace(target, source, keys?)targetMerge `source` into `target` and removes from `target` keys not present in `source`
memofnsignalread-only signal that will update when the return value of the function changes, memos are lazy
writablefnsignallike 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
rootfndispose functioncreates a new tracking scope
effectfnvoidfunction to re-run when dependencies change
syncEffectfnvoidfunction 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>) => anyanyfor when you need to run effects one after another you can await the previous running effect with the parameter that the callback receives.
batchfnvoidbatches changes
cleanupfnvoidcleanup callback for when the reactive context is disposed
ownedfnowned functionreturns a function that holds the owner on the scope. If you call it will run the function you passed initialy with that owner
withValuewithValue(value, fn) => fn(value)voidgiven 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
mapmap(Iterable, callback)voidreactive version of array.map for iterables