Comments (3)
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.
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.
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)
- Backbone send null for unset relations HOT 1
- Backbone Relational dealing with model instances with the same ID HOT 2
- Retain model in collection when unsetting on another relationship HOT 1
- Models without id (only cid) are not registered in Backbone.Relational.Store HOT 1
- Doesn't work with lodash 4.1.0 HOT 1
- Is this project abandoned? HOT 6
- Backbone 1.3.2 support HOT 2
- using toJSON to serialize data HOT 3
- Update documentation for ES2015/CommonJS importing
- JSBin example HOT 1
- Rename Backbone-relational to backbone.relational HOT 4
- Double imports for using with webpack HOT 5
- ES2015 Refactor (Release Checklist) HOT 1
- Store causing huge memory retention and cleanup takes forever HOT 2
- How do I get Backbone-relational working with ES6? HOT 6
- Problem defining relations: "model does not inherit from Backbone.RelationalModel" HOT 6
- getAsync() fails when retrieving to many models using set URL HOT 4
- don't initialize related Model/Collection in defaults HOT 2
- Collection instances share `options` object by reference which is unexpected
- Backbone-relational compactibility with typescript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone-relational.