-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
spike for prop notification #586
base: master
Are you sure you want to change the base?
Changes from 1 commit
b38d79c
a794db2
b780c13
4d1469a
907ee21
b232cd9
65b528b
a186905
68c426e
4ad58ce
a93ddeb
a345077
17380df
f680506
d59a4ec
218ff11
b5f30fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,31 +32,31 @@ function maybeUnwrapProxy(o) { | |
return isProxy(o) ? maybeUnwrapProxy(safeGet(o, 'content')) : o; | ||
} | ||
|
||
function tryContent(ctx) { | ||
function getContent(ctx) { | ||
return ctx._content ? ctx._content : ctx.content ? ctx.content : ctx; | ||
} | ||
|
||
function deepNotifyPropertyChange(changeset, path) { | ||
let paths = path.split('.'); | ||
let maybeDynamicPathToNotify = null, | ||
lastPath = paths.pop(), | ||
current = changeset, | ||
current = getContent(changeset), | ||
i; | ||
|
||
//If the path doesn't exists previously exist inside the CONTENT, this is a dynamic set. | ||
let existsInContent = safeGet(changeset[CONTENT], path) !== undefined; | ||
|
||
for (i = 0; i < paths.length; ++i) { | ||
const curr = current[paths[i]]; | ||
if (existsInContent && curr && curr.content === curr.content) { | ||
current = current[paths[i]]; | ||
const curr = safeGet(getContent(current), paths[i]); | ||
if (existsInContent && curr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this fail if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping! |
||
current = curr; | ||
} else { | ||
maybeDynamicPathToNotify = paths[i]; | ||
break; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm understanding this correctly, we want to traverse down the object to the leaf key, calling notify property change as we go? Or do we want to reduce property notifications (as indicated in the issue) and only want to notify at the leaf key in Two questions.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrote my last comment as my understanding changed. The idea is to traverse down to find the deepest example 1. The output should: example 2. The output should: example 3. The output should: I think this could be optimized like this: for (i = 0; i < paths.length; ++i) {
if (current[paths[i]] != undefined) { // we can still go deep
current = current[paths[i]];
} else {
//we just found that its a dynamic set, so we notify here and stop, no point in going further.
notifyPropertyChange(tryContent(current), paths[i]);
return;
}
}
//We didn't stop, we haven't notified, and we went the deepest as possible, so we notify there.
notifyPropertyChange(tryContent(current), lastPath); I think its ok to start from the top, because we can early notify and return |
||
} | ||
const pathToNotify = maybeDynamicPathToNotify ? maybeDynamicPathToNotify : lastPath; | ||
notifyPropertyChange(tryContent(current), pathToNotify); | ||
notifyPropertyChange(current, pathToNotify); | ||
} | ||
|
||
export class EmberChangeset extends BufferedChangeset { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
_content
meant to capture from the Changeset andcontent
from an ObjectProxyNode?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sry for stringing this along but I do want to get a solution in. I'm learning from your work to understand the issue better.
So is it best to say, not only does notifyPropertyChange not work for nested keys (this is obvious to me), but also we are notifying on the wrong object? Meaning
notifyPropertyChange(this, key)
leads to the wrong/no expected behaviour as well? I wouldn't have through this would have work for an ObjectProxyNode (non Ember object, etc)