Coder Social home page Coder Social logo

The path.. about observ HOT 2 CLOSED

gnimmelf avatar gnimmelf commented on September 26, 2024
The path..

from observ.

Comments (2)

Raynos avatar Raynos commented on September 26, 2024

@gnimmelf observ is a single value. you listen to it and you get the entire new value when it changes.

@gnimmelf if you take a look at observ-struct and observ-array you can see they both support a feature called _diff

https://github.com/Raynos/observ-struct/blob/master/index.js#L39-L42
https://github.com/Raynos/observ-array/blob/master/splice.js#L45

In observ-struct and observ-array the _diff property is the most recent thing that caused a change, it is both the path and the value.

If you nest observ-struct and observ-array recursively the _diff will be a deeply nested diff object that will give you this information!

One trick I use in mercury a lot is

var state = window.state = mercury.struct({ 
  ...
})

Then in the browser dev tools I do window.state(function (x) { console.log('diff', x._diff) })

So I basically see exactly what changes when I click around :)

from observ.

gnimmelf avatar gnimmelf commented on September 26, 2024

Indeed! Cool. Then it's settled: I'll swap out my own "masterpiece" with mercury.struct :-)

from observ.

Related Issues (9)

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.