State Doesn't Get Defaulted And Values Don't Change
So i am making a reactive state system where the developer of a component can supply a default state and other states if they want. The default state is used when nothing is active and regarding the states. The code checks on the array to say which is active, the way the state array is orchestrated, it uses the first active state present in the list
Each state has specific values to it, like color & other stuff. The
STATE DEFAULTING EFFECT
gets triggered and correctly switches the state. However the STATE DEFAULTING MEMO
is not triggered. For some reason when i get the style field, even tho it does supply the correct value. The values do not get updated
For context getterFromReactive
"normalizes" the values into just accessors. It does create a effect for checking whenever the value is changed or not and update the returned value accordingly
17 Replies
tho idk if i explained it good enough tbh
do yall point out any sort of confusions
oh wait
pretty odd
so the first bug was eliminated
for the second
when i use
getStyleField
and the state changes
for some odd reason
even tho they access the same thing.getStyleField('...')
must be reading/unboxing the memo early (out side of the first // DOESN'T WORK effect).
You'll have to share your getterFromReactive
code for closer inspection.
Is getterFromReactive
something like this?
https://playground.solidjs.com/anonymous/fb6c4743-abea-4b5f-882b-826d99e84db0fixed it
kind of
i took the "lazy" approach of making the values as store and the name as a signal
instead of making the the entire object
here is the code for the getterFromReactive
and for
ReactiveTypeGetter
What is the intended type signature of the inner
createSignal
?
Its like a store of a lambda, but then it is set by a potentially non-lambda in createRenderEffect
.
There might be a cleaner way to implement getterFromReactive
without requiring createRenderEffect
hmm
thats a good question, idk why i putted createSignal from before
thats the issue
func
is a utility to map the value on the way out?yeh
i use it sometimes for getting a unit for example. The
parseUnit
func is used which just converts it into a unit representation
Maybe (inside else-if branch)
tho what happens if the value changes
the new value has to be reflected
so the function has to be executed again
It will
oh
But... not optimimal, because the func will execute always even if read again with no change.
mhm\
U could use a createMemo there, but the reactive lifespan of the memo will only last the lifespan of the reactive scope it was called with.
Thats why I have that
ReactiveCache
utility.ok
Gotta go... been cool catching up.
yeh gtg too
cya