Giter VIP home page Giter VIP logo

Comments (4)

ZiadJ avatar ZiadJ commented on June 19, 2024

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.

grennis avatar grennis commented on June 19, 2024

I don't think this works correctly when items are added or removed from the child array.

from knockoutjs-reactor.

ZiadJ avatar ZiadJ commented on June 19, 2024

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.

ZiadJ avatar ZiadJ commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.