[Question]: Plan to support nested object as initialState
Closed this issue ยท 2 comments
aelbore commented
thanks for this lightweight signal base library, Is there any plan to support nested object as initialState? if this is out of scope its fine :) you can close this github issue
WebReflection commented
you can add support to anything you like through the equals
option as explained in solid-js documentation.
const deep = signal(anyObject, {
equals(newVal, oldVal) => {
// compare the 2 objects as you like
// returns true if these don't need to be replaced
// false otherwise
}
});
WebReflection commented
P.S. just realized the newVal and oldVal order is inverted in here (weird solid went for that instead of (prev, curr) and also the new value is not attached ... fixing that as we speak.