Comments (4)
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.
from knockoutjs-reactor.
I don't think this works correctly when items are added or removed from the child array.
from knockoutjs-reactor.
I've put up a beta version of the code that supports it here:
https://github.com/ZiadJ/knockoutjs-reactor/blob/master/knockout.reactor.latest.js
Sorry I haven't had much time to test it yet but feel free to let me know if you come across any bugs.
from knockoutjs-reactor.
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 depth
value allows it to reach your nested elements.
P.S recurse
has been replaced by depth
in the latest version.
from knockoutjs-reactor.
Related Issues (20)
- disposal does not work when mutable and not oldValues
- Multiple watch break on dispose HOT 2
- Bower Accessible HOT 12
- Cannot ignore observable arrays HOT 3
- AMD module support HOT 2
- How can we reset it? HOT 1
- Not Compatible with knockout 3.4 HOT 3
- Uncaught Subscriptions field (.G) not defined for observable child HOT 3
- Issue with KO 3.3.0 and the minified reactor HOT 1
- "un-watch" functionality... HOT 1
- New release? HOT 3
- Uncaught Subscriptions field (.K) not defined for observable child Error only when using knockout.debug HOT 9
- npm ko-reactor version is stuck at 1.3.7 HOT 7
- Not working corrrectly with KO 3.4.2
- Keep notifying changes for replaced objects
- Bad parents in the notifications when sub-objects are replaced
- Basic functional test suite HOT 1
- How use a ko-reactor with require() and webpack?
- Missing "main" declaration in package.json HOT 1
- KO Reactor / KO Undo Manager compatibility (context is not a function) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knockoutjs-reactor.