-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
addons.update directive precedence order #1615
Comments
My first instinct would be to say that you can use exactly one directive or do nested updates, not both. |
Something I've been fiddeling with myself: https://gist.github.com/syranide/0d0c7798c18be3f8a243 (not finished) Might be an interesting alternative, avoids the use of directives in favor of regular manipulation. |
There's lots of interest in coming up with better (user) solutions to this problem. ref = Ref({})
ref.set_in('a/children/0/children/2', 2) would set the new value according to existing path. When the path does not exist, it's possible to build correct nodes (object or array) according to a json schema if available. Instead of trying to combine multiple 'update operations' in a single line, I think it's best to just have a different mecanism for batching/transacting the multiple operations when that's desired, such as |
@pedroteixeira I agree with this and have build some similar path mecanism instead of using an "object path". |
Since we're deprecating Update in favour of immutable-js, I think, beside existing bug fixes + some low hanging feature requests, we won't be adding a whole new syntax for updating nested collections like json paths. (FYI, immutable-js and Clojure uses That being said, I agree with @spicyj. Yes, the ordering is arbitrary right now, but you probably shouldn't rely on it the same way you can't do If that makes sense, can we close this? (@petehunt) |
@chenglou It is not GCC ADVANCED_MODE-compatible though I think? |
@pedroteixeira if you are interested I build my framework around Om/cursor concepts and used React update and paths. It is probably not the most efficient and clean code but it does the job well and is in production :) My Atom implementation support transactions and allow to do something like this on dom events:
During a transaction, you can read your writes. |
We are handing over |
Is this a sane ordering for handling these directives? I'd never want to have
update
recurse into something I've already$push
ed,$unshift
ed, or$splice
d in -- otherwise I would have included the changes in those directives' arguments originally. I think the most natural expectation would be that update should recurse into existing elements at their indices in the original array, then splice in the$splice
directive, then$push
and$unshift
new elements to ensure they appear at the ends of the resulting array, like this:As it is now, for certain cases, the programmer would have to introduce difficult-to-visually-inspect index-twiddling logic or split the changes up among multiple calls to
update
to produce the desired result.The tests for
update
don't include any cases where multiple directives appear for a single value, so I'm not sure whether this is intentional or whether anybody depends on this behavior. But especially when you're dealing with trees of this form:the current behavior really doesn't allow for the same visual clarity that makes
update
so helpful for trees composed entirely of objects.The text was updated successfully, but these errors were encountered: