generated from nvim-lua/nvim-lua-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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.- Passing an complex object to
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:
- 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
pairswill 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
__newindexto be called.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request