Reactive Props V2 #71
Reference in New Issue
Block a user
No description provided.
Delete Branch "reactive-props-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The original reactive props system was based on a naive implementation (a hard-coded pattern match for the shared and props tables in a prop and a metatable to detect reads/writes on the shared table) that was proving difficult to extend further. This PR rebuilds the reaction system to be based on a new primitive,
basalt.reactive, which is not coupled to the environment. It also does away with the naive pattern matching. Any global variable can now be accessed in a reactive prop. Additionally, reactive props are now full Lua expressions, which are computed to return a value. This makes it possible to do things like this:Internally, this works in much the same way that Signals work in Solid.js. We populate a list of observers for a reactive value on the first pass render, based on calls to their respective get functions. A subsequent call of the set function will then update all these observers.
Other changes