realar-project / realar

5 kB Advanced state manager for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proposal: reset.by and update.by (the "sub" should be removed)

betula opened this issue · comments

const r = signal();
const u = signal<number>();

const v = value(0);

v.reset.by(r);

v.update.by(u, (state, up_value, up_value_prev) => {
  return state + (up_value - (up_value_prev || 0));
});

u(10);
r();

And I think to vary interesting idea is the convert "reset" function method to signal

const a = value(0);

a.reset.to(() => console.log("reset"));

Added to "the stream of conciseness 0.7+ roadmap"