realar-project / realar

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

low: proposal for link (or bind) decorator for binding value to prop #56

Closed betula closed 3 years ago

betula commented 3 years ago

No have possibility to use "bind", because in classes with decorators style exists a usually "bind" decorator function that means bind context of the class method to this.


const v = value(0);
class A {
  @link v = v;
}
console.log(shared(A).v); // 0

For example, the cache alias will be

class A {
  @link c = selector(() => 0);
}
shared(A).c // 0

But no possible to reassign.

betula commented 3 years ago
class Logic {
  @link lang = sharedLocale().$lang
}

Hmm.

Only one normal case I can find from all

class A {
  search = pool(async () => 0);
  @link pending = this.search.pending

}

But it's not enough for a proposal approval.