WebReflection/usignal

[Question]: Plan to support nested object as initialState

Closed this issue ยท 2 comments

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

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
  }
});

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.