realar-project / realar

5 kB Advanced state manager for React
MIT License
45 stars 0 forks source link

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

Closed betula closed 3 years ago

betula commented 3 years ago
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();
betula commented 3 years ago

useScopedValue, useSharedValue, useLocalValue - declined Other implemented in 0.6.0