realar-project / realar

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

low proposal: add automatic unsubscribe for previous time creations in all reaction places #57

Closed betula closed 3 years ago

betula commented 3 years ago
class A {
  @prop m;
  constructor() {
    k_signal.watch(k => this.m = k);
  }
}

k_signal.view(k => new A());

let t;
(cycle and loop)(() => {
  (await )k_signal;
  t = new A();
});

Automatic unsubscribe k_signal.watch... When? At the next iteration, but

loop(() => {
  if (await k_signal) {
    t = new A();
  }
});

In that case, automatic destroy should be not on the next iteration.

betula commented 3 years ago

Hmmm. Declined.