Created
April 27, 2013 05:41
-
-
Save brian-mann/5472020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @PlanetExpress.module "Entities", (Entities, App, Backbone, Marionette, $, _) -> | |
| App.commands.setHandler "when:fetched", (entities, callback) -> | |
| xhrs = _.chain([entities]).flatten().pluck("_fetch").value() | |
| # if _.isArray(entities) | |
| # xhrs.push(entity._fetch) for entity in entities | |
| # else | |
| # xhrs.push(entities._fetch) | |
| $.when(xhrs...).done -> | |
| callback() |
mikefowler, _fetch is "private" property of Backbone Model, therefore it isn't described in API documentation
When looking at the annotated source _fetch isn't located anywhere on the page.
It turns out that Brian has overridden the Backbone.sync method to add the _fetch property.
do (Backbone) ->
_sync = Backbone.sync
Backbone.sync = (method, entity, options = {}) ->
sync = _sync(method, entity, options)
if !entity._fetch and method is "read"
entity._fetch = sync
sync
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Brian… been implementing your loading view the past few days, the one from Backbone Rails. Regarding this method above, in particular… where is the "_fetch" key on the entities coming from? From what I can tell I don't see Backbone ever add that property to a model or collection. Am I missing something?