Skip to content

@preact-signals/[email protected]

Compare
Choose a tag to compare
@github-actions github-actions released this 28 Nov 23:22
· 269 commits to main since this release
6f75c99

Minor Changes

  • d3bbcd3: Added WritableUncached which receives getter and setter functions.

    const a = signal({ a: 1 });
    const aField = $w({
      get() {
        return a().a;
      },
      set(value) {
        a({ a: value });
      },
    });
    
    console.log(aField.value); // 1
    aField.value = 2;
    console.log(aField.value); // 2
    console.log(a.value); // { a: 2 }
  • 8ad6ae2: Added rafReaction for easier integration with raw DOM.

    rafReaction

    Will execute reaction after deps changed on next animation frame. Return dispose function.

    const sig = signal(1);
    const el = document.createElement("div");
    
    rafReaction(
      // deps
      () => sig.value,
      // effect
      (value) => {
        el.style.transform = `translateX(${value}px)`;
      },
    );
    
    sig.value = 10;