Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mulderp
Created April 27, 2014 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mulderp/11349911 to your computer and use it in GitHub Desktop.
Save mulderp/11349911 to your computer and use it in GitHub Desktop.
returns undefined ?
var Sync = function(syncing, options) {
this.syncing = syncing;
this.url = syncing.url;
this.delay = syncing.delay;
}
_.extend(Sync.prototype, {
findAll: Promise.method(function() {
var sync = this;
return Promise.bind(this).then(function() {
request.get(sync.url).set('x-delay', sync.delay).end(function(res) {
return res.text;
})
})
})
});
Collection = function() {}
_.extend(Collection.prototype, Events, {
sync: function(options) {
return new Sync(this, options);
},
fetch: Promise.method(function() {
this.trigger('fetching');
return this.sync()
.findAll()
.then(function(movies) {
console.log(movies);
return movies;
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment