Code Monkey home page Code Monkey logo

Comments (6)

offthegrass avatar offthegrass commented on May 22, 2024

sounds sensible

how about if you use .data() inside constructor: -> it is considered structural, and anywhere else it's referential?

from meteor-blaze-components.

mitar avatar mitar commented on May 22, 2024

I do not think that having different semantics based on where you call a function is a good API.

from meteor-blaze-components.

offthegrass avatar offthegrass commented on May 22, 2024

could have the default behaviour as referential, and a parameter for setting as structural

.data({structural:true})

from meteor-blaze-components.

mitar avatar mitar commented on May 22, 2024

I think we should leave default behavior as it is in Blaze. Just to minimize surprises. Default Blaze behavior is the most conservative one, it means functions/methods are rerun more often, but then Blaze does not necessary really modify DOM if everything stays the same. So this is a good default. It does not introduce any errors.

from meteor-blaze-components.

mitar avatar mitar commented on May 22, 2024

In fact, because I have not seen really non-object data contexts in practice, this means that the whole Blaze behavior is more similar to React.js: rerun everything and then compare with DOM and patch it if there are changes. The issue is that React.js uses virtual DOM do make comparison, while Blaze I think compare with real DOM. And reading real DOM is a bit slower than virtual DOM.

from meteor-blaze-components.

mitar avatar mitar commented on May 22, 2024

I think now that we have computed fields this is not really necessary. If you need different equality you can do:

onCreated: ->
  @dataStructural = new ComputedField (=> @data()), EJSON.equals

And this is it. :-) And then you can call @dataStructural() to get data context which will trigger reactive change only when data is structurally different.

For referential equality:

onCreated: ->
  @dataReferential = new ComputedField (=> @data()), (a, b) => a is b

from meteor-blaze-components.

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.