useDeepCompareEffect in solid
How would I do something like this in
solid-js
(would I do this)?
8 Replies
1. a normal effect with the
prev
parameter used in the callback
2. read from signal/signals that you wish to track
3. compare them how you want
if they match, return early prev value
if they do not match, do your logic and return new value
You can also use a memo as a cashe/equality check layer
with passing the equals
option to itSry, but I don't get it.
Could you write it up?
It doesn't sound complicated, but... idk
So this would do it:
Since I want to execute this effect callback.
Sure
it kills computability a bit, but should work
I don't know if it is a good solution. It's a bit different in React. I feel like
deps
should have a different type, but that would kill reactivity, wouldn't it?createDeepCompareMemo would probably be a more universal abstraction
on(deps, (a, b, c) => dequal(a, b) ? c : fn(a, b, c))