realar-project / realar

5 kB Advanced state manager for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

low: proposal api for using local, scoped and shared with value return

betula opened this issue · comments

const factory = () => {
  const count = value(0);
  const inc = count.updater((value, [...args]) => value + 1);          // proposal
  const dec = count.updater((value) => value - 1);
  return () => ({
    count: count.get(),
    inc, dec
  });
}

const Custom = () => {
  useScopedValue(factory).inc();
  useSharedValue(factory).inc();
  useLocalValue(factory).inc();
}

t.to(k.updater((k_v, t_v, prev_t_v) => next_k_v));         // proposal updater using
t.to(k);
t.to.once();
t.to.sync();

useScopedValue, useSharedValue, useLocalValue - declined
Other implemented in 0.6.0