Skip to content

Releases: Feavy/signal

v1.1.0

18 Feb 13:13
Compare
Choose a tag to compare

refactor: better nested batches handling

Use a counter instead of a boolean to count nested batches. Observers are triggered when the counter reaches 0.

feat: signal object's methods changes are batched

This prevent extra observer calls when a method modifies more than one property.

class Vec2 {
  constructor(public x: number, public y: number) { }

  public set(x: number, y: number) {
    this.x = x;
    this.y = y;
  }
}

const pos = new Signal(new Vec2(0, 0));

observe(() => {
  console.log("position:", pos.value.unwrapped);
}); // Prints: "position: { x: 0, y: 0 }"

pos.set(1, 2); // Prints: "position: { x: 1, y: 2 }" <-- the observer is called only once

feat: add signalify function to transform any object into a reactive one

const position = {x: 0, y: 0 };
signalify(position);

observe(() => {
  console.log("position:", (position as Signal<Vec2>).value.unwrapped);
});  // Prints: "position: { _x: 0, _y: 0 }"

(position as Signal<Vec2>).value = { x: 1, y: 2 };  // Prints: "position: { _x: 1, _y: 2 }"

1.0.0

17 Feb 20:21
Compare
Choose a tag to compare
README

v0.0.5

17 Feb 08:46
Compare
Choose a tag to compare

Test

v0.0.4

17 Feb 08:41
Compare
Choose a tag to compare

Test

v0.0.3

17 Feb 08:38
Compare
Choose a tag to compare

Test

v0.0.2

17 Feb 08:24
Compare
Choose a tag to compare

Publish from github