Skip to content

Commit

Permalink
improve notif
Browse files Browse the repository at this point in the history
  • Loading branch information
betocantu93 committed Apr 16, 2021
1 parent b232cd9 commit 65b528b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ function tryContent(ctx) {
}

function deepNotifyPropertyChange(obj, path) {
var paths = path.split('.');
var lastPath = paths.pop(),
let paths = path.split('.');
let maybeDynamicPathToNotify = null,
lastPath = paths.pop(),
current = obj,
i;

let exists = safeGet(obj._content, path) !== undefined;

for (i = 0; i < paths.length; ++i) {
if (current[paths[i]] != undefined) {
const curr = current[paths[i]];
if (exists && curr.content === curr.content) {
current = current[paths[i]];
} else {
notifyPropertyChange(tryContent(current), paths[i]);
maybeDynamicPathToNotify = paths[i];
break;
}
}
notifyPropertyChange(tryContent(current), lastPath);
const pathToNotify = maybeDynamicPathToNotify ? maybeDynamicPathToNotify : lastPath;
notifyPropertyChange(tryContent(current), pathToNotify);
}

export class EmberChangeset extends BufferedChangeset {
Expand Down

0 comments on commit 65b528b

Please sign in to comment.