Add createLens
primitive
#453
Labels
Primitive Proposal
For discussing a primitive proposition and the API design
createLens
primitive
#453
Describe The Problem To Be Solved
Utilities for working with nested reactivity in a modular way.
See previous discussion:
Originally described by @clinuxrulz:
Suggest A Solution
Proposed primitives:
createLens
- Given a path within a Store object, return a derived or "focused"getter and setter pair.
createFocusedGetter
- The first half of the lens tuple; a derived Signalusing path syntax on an object.
createFocusedSetter
- The second half of the lens tuple; a Setterfor a specific path within a Store.
I've started a PR to explore this concept (WIP): #452
It's essentially just syntactic sugar on top of regular Stores, with some tricks to maintain Typescript support.
In previous discussion people theorized about a performance benefit from this approach as well, by caching a partially applied path within the Store object -- for example: solidjs/solid#506 (comment).
I'm not as familiar under the hood of how the Store works, so my goal will be the replicate the intended DX and then unit test thoroughly enough that someone else could come in and work some performance magic. For now it is Lens-like DX with the same behavior/performance as a regular Store.
I'm also curious to get people's thoughts on:
Cheers 🍺
The text was updated successfully, but these errors were encountered: