Giter VIP home page Giter VIP logo

Comments (3)

PaulUithol avatar PaulUithol commented on September 6, 2024

Been thinking about this a bit, I'm still not entirely sure what you're looking for though. Do you mean something like a global handler that triggers an event whenever any Backbone.RelationalModel instance triggers a 'change', 'add', or 'remove'?

That should be possible - we'd probably have to find a way so we don't get a lot of duplicate events flying around. Don't want to have to bind three events for each model either; maybe Backbone.store could relay those event, sort of like Backbone.Collection is doing as well for Backbone.Model events?

from backbone-relational.

dvv avatar dvv commented on September 6, 2024

Lemme elaborate. Suppose I have A which hasMany B which hasMany C. When I run add on C, to listen to add event i must bind a handler to B, when I run add on B I should listen to events at A. NP, it's easily done by overriding initialize(), but event names themselves are not informative -- add:C gives no info about C is subordinate of B which is subordinate of A. add:A.B.C would be better.

I want to employ this repo means to construct kinda arbitrary depth models (Backbone only supports one level (shallow) properties). Say, (new DeepModel({})).set({foo:{}}).set({foo:{bar:'bar}}) whould generate change:foo and change:foo.bar. Given this pattern, each RelationalModel should have full "path" specifier, along with key.

from backbone-relational.

PaulUithol avatar PaulUithol commented on September 6, 2024

Could you take a look at the cascadeEvents branch? It's a bit of a proof of concept, trying to get my head around how to do this best. Is this anywhere near what you meant? I'm still trying to figure out how to make this as useful as possible in a broader sense.

Some things to note:

  • it's a bit complicated (the whole thing is actually), plenty of unforeseen consequences are possible
  • I don't immediately see how this can be made usable; you probably don't want to bind every possible permutation of update:*?
  • it would be nice if the 'path' could be used as the argument for get as well (say, model.get('parent.children(2)')
  • performance... I'm sure firing an event on every model for a change on any model (which is what this boils down to, for any moderately connected graph) can't be good for performance, and will get worse the larger your set of objects becomes

from backbone-relational.

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.