-
Notifications
You must be signed in to change notification settings - Fork 23
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
Reactor recursion doesn't work #2
Comments
Thanks for the suggestion. I quickly modified the code to get it to work in your case. To test it you need to replace lines 62 to 72 with this: function watchChildren(object, recurse) {
if (recurse && (recurse === true || recurse >= 0)) {
if (typeof object === 'object') {
watchObjectOrArray(object, recurse === true || Number(recurse) - 1);
} else if (ko.isSubscribable(object)) {
if (object() instanceof Array)
watchObjectOrArray(object(), recurse === true || Number(recurse) - 1);
}
} else if (ko.isSubscribable(object)) {
context.watch(object, options, valueEvaluatorFunction);
}
}
function watchObjectOrArray(object, recurse) {
// Listen to all subscribables within specified object or array.
if (typeof object === 'object') {
for (var property in object)
watchChildren(target[property], recurse);
} else if(object instanceof Array) {
for (var i = 0; i < object.length; i++)
watchChildren(object[i], recurse);
}
}
options.targetParent = target;
watchObjectOrArray(target, options.recurse); Please let me know your thoughts about it and I'll update the source once it passes your tests. |
I don't think this works correctly when items are added or removed from the child array. |
I've put up a beta version of the code that supports it here: Sorry I haven't had much time to test it yet but feel free to let me know if you come across any bugs. |
It's been a while since I've last been around and I've finally fixed the issue. I've tested it against large and complex object graphs generated by BreezeJS. So everything should work fine now as long as the P.S |
The following test case for recursion doesn't appear to work (ko 2.2.1, ko.mapping 2.4.0):
The text was updated successfully, but these errors were encountered: