Note:
object == lua table in this ticket
Problem:
create_signal is fine for primitive values and state that only lives within the same component or few children of it. Things are not that simple when you want share the same state to many components spread through out the application. Prop drilling is one option and good in terms of re-usability of components though it's could become a complete mess.
- Passing an complex object to
create_signal works but updating it makes every component/effect using that signal to re-render even if the update is a partial update.
Possible Solutions:
- Write a wrapper for Lists and Maps
- Redux.useSelector like hook to extract the used part of the store and trigger a re-render only if the value is changed
I have tried
Using wrapper for key, value stores using __index & __newindex.
Pros:
- Exact dependencies of an object can be tracked & only the effects that's using the dependencies can be used
Cons:
- Though you can index, reality is, it's not the initial object you passed. So store or part of it can not be treat as an object. For example passing it to
pairs will through an error.
- Updating the values should be done through a dict-node & value has to be indexed before a new value is assigned in order
__newindex to be called.
Note:
object == lua table in this ticket
Problem:
create_signalis fine for primitive values and state that only lives within the same component or few children of it. Things are not that simple when you want share the same state to many components spread through out the application. Prop drilling is one option and good in terms of re-usability of components though it's could become a complete mess.create_signalworks but updating it makes every component/effect using that signal to re-render even if the update is a partial update.Possible Solutions:
I have tried
Using wrapper for key, value stores using
__index&__newindex.Pros:
Cons:
pairswill through an error.__newindexto be called.