-
Notifications
You must be signed in to change notification settings - Fork 9
Introduce deep paths for bindings and make views work with propagators #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will let us create block structures.
These types are all interdependent upon each other. Easier to have them in a single module.
...and change factory naming convention to just vnode, binding, block, etc.
... mustache calls {{#these}}{{/these}} sections.
Lets us get deep properties on objects or classes via either the `path` method, or by deep property access.
...and factor cancel out of renderNode. Make it part of the return signature.
- Add tests - Batch on microtask instead of animationframe - Add name to cell - Remove ID from cell
...instead of bespoke State class.
- Define propagator lens in terms of lens type.
Uses vector clock to solve diamond problem.
- a type is mergeable if it implements merge(value: this): this - function `merge<T>(prev: T, curr: T): T` will take any two values and merge them using merge method if mergeable, or deferring to curr if not mergeable - now we can remove the update function in the cell signature. The type knows how to update itself. - This lets us simplify the cell signature - We can drop state, which was just a wrapper for cell that had LWW semantics. Now all non-mergeable values have LWW semantics. - Mergeable will let us implement things like accumulating explanations on the datatype about what changed and why. We can use these during generation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a set of interdependent changes for deep key paths on bindings, as well as the beginnings of a propagator implementation.
To implement
{{deep.paths.in.bindings}}we needed to introduce the concept of a "mapped reactive cell". The simplest way to do this turned out to be to create the beginnings of a propagators implementation.For more on propagators, see
Additions:
@commontools/common-propagatorpackage which offers a basic propagator implementationMergeableinterface (any type that implements.merge().lift()function to propagator for 1-8 argumentslens()to create a cell that bi-directionally reflects the lensed contents of another cellkey()to create a cell that bi-directionally reflects a subkey of another cell{{a.b.c}}{{a.b.c}}are parsed into array paths `['a', 'b', 'c'] in view objects.path()that allows for deep pathing into objects.Keyable(exposes a.key()method), this will be used to descend into the structure.KeyableforCell, returning a mapped cell that bi-directionally reflects the sub-path of the parent.Changes:
view.js. These types are all interdependent on each other. Better to have them in one module to avoid circular dependencies.vnode.tagchanged tovnode.name. This is more appropriate, since we use name for other view node types, and the name may not always be a tag (in the case of documentfragment).Reactive,Cancel, and some other supporting types have been moved into common propagator@commontoos/common-propagator/reactive.jshtmltemplate holes are filled with names generated bytid()rather thancid().Removed:
Unchanged:
render()will happily bind primitive values, OR any value that implements.sink()..sink()Improvements: