Code Monkey home page Code Monkey logo

Comments (5)

matthewp avatar matthewp commented on August 21, 2024

The thing that's fuzzy to me is if we should tear down the observations if something else is using it. Or if it would be possible for something else to be using that observation.

from can-observation.

justinbmeyer avatar justinbmeyer commented on August 21, 2024

The thing that's fuzzy to me is if we should tear down the observations if something else is using it. Or if it would be possible for something else to be using that observation.

I think it's extremely unlikely that something else is using the other observations but SHOULD NOT be torndown when the outer observation is re-calculated.

from can-observation.

matthewp avatar matthewp commented on August 21, 2024

The way this is implemented makes an assumption that any observations created within another observation will always be recreated whenever the parent observation is updated.

This is not always the case, for example when the child observation is cached. This is the case with can-stache, which caches observations it creates for perf reasons. See here

from can-observation.

matthewp avatar matthewp commented on August 21, 2024

I'm trying a slightly different approach than what is in #131. Instead of destroying all children whenever an observation is updated, will instead provide an API: trapBindings that traps calls to can.onValue. Pseudocode or how that will be used:

function fn() {
    // priority 2
    var foo = new Observation(function foo(){
        var val = bar.get();
        fooUpdates++;
        return val;
    }, {isObservable: false});

    var stopTrap = foo.trapBindings()
    Bindings.start()
    view.live(foo);
    ObservationRecorder.addBindings( stopTrap() )

    
    return foo.get();
}

from can-observation.

matthewp avatar matthewp commented on August 21, 2024

We are going to defer doing this change (and removing can-view-nodelist) for now. I wrote up this gist which describes where I got with the task and what the next steps would be.

from can-observation.

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.