@iliasbhal As a simple getter this could work for expression dependencies, just like a getter on any object, but it wouldn't be reactive, still 100% pull based. Then it would require memoization, unless the spec for this syntax has a special rule allowing JS engines to re-calculate values only on first use if it is "dirty". I think an if-dirty memoization feature could work. Hmm
The advantage of the idea in Dependency-tracking reactivity - #7 by trusktr is that we could also have a reactivity system, not just derived values.
For a dependency-tracking reactivity system, I think we need some way to opt into it syntactically, otherwise we need to provide a non-syntactical API much like libs like S.js and Solid.js do because if we overloaded regular JavaScript syntax to re-run then it means semantics of JS itself would be modified, which is impossible without breaking everyone.
get
variables could be a syntactical way to opt into having "signals", assuming we can have at least a non-syntactical API given to us by the JS engine for being able to re-run expressions when their values change (like S()
in S.js, or createEffect
in Solid.js).