Created
April 27, 2014 16:33
-
-
Save mulderp/11349911 to your computer and use it in GitHub Desktop.
returns undefined ?
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
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