This file contains 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
try { | |
var users = getJSON('/users'); | |
var companies = getJSON('/companies'); | |
var contacts = getJSON('/contacts'); | |
return [users, companies, contacts]; | |
} cacth (e) { | |
//handler error | |
} |
This file contains 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
BulkLoader.prototype.load = function(callback){ | |
var self = this; | |
$.getJSON('/login').done(function(data) { | |
$.getJSON('/users').done(function(data) { | |
self.users = data; | |
$.getJSON('/companies').done(function(data) { | |
self.companies = data; | |
$.getJSON('/contacts').done(function(data) { | |
self.contacts = data; |
This file contains 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
try { | |
var users = getJSON('/users'); | |
var companies = getJSON('/companies'); | |
var contacts = getJSON('/contacts'); | |
return [users, companies, contacts]; | |
} cacth (e) { | |
//handler error | |
} |
This file contains 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
export default function async(generatorFunc) { | |
function continuer(verb, arg) { | |
var result; | |
try { | |
result = generator[verb](arg); | |
} catch (err) { | |
return RSVP.Promise.reject(err); | |
} | |
if (result.done) { | |
return result.value; |
This file contains 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
BulkLoader.prototype.load = function(callback){ | |
var self = this; | |
$.getJSON('/login').done(function(data) { | |
$.getJSON('/users').done(function(data) { | |
self.users = data; | |
$.getJSON('/companies').done(function(data) { | |
self.companies = data; | |
$.getJSON('/contacts').done(function(data) { | |
self.contacts = data; |
This file contains 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
try { | |
var users = getJSON('/users'); | |
var companies = getJSON('/companies'); | |
var contacts = getJSON('/contacts'); | |
return [users, companies, contacts]; | |
} cacth (e) { | |
//handler error | |
} |
This file contains 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
BulkLoader.prototype.load = function(callback){ | |
var self = this; | |
$.getJSON('/login').done(function(data) { | |
$.getJSON('/users').done(function(data) { | |
self.users = data; | |
$.getJSON('/companies').done(function(data) { | |
self.companies = data; | |
$.getJSON('/contacts').done(function(data) { | |
self.contacts = data; |
This file contains 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
BulkLoader.prototype.load = function(callback){ | |
var self = this; | |
return new RSVP.Promise(function(resolve, reject) { | |
return getJSON('/login').then(function(token) { | |
return RSVP.hash({ | |
users: getJSON('/users'), | |
contacts: getJSON('/contacts'), | |
companies: getJSON('/companies') |
This file contains 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
BulkLoader.prototype.load = function() { | |
var self = this; | |
return async(function * () { | |
try { | |
self.users = yield getJSON('/users'); | |
self.contacts = yield getJSON('/contacts'); | |
self.companies = yield getJSON('/companies'); | |
return self; |
This file contains 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
function * oneToThree() { | |
yield 1; | |
yield 2; | |
yield 3; | |
} | |
var iterator = oneToThree(), | |
obj = {}; | |
while(!obj.done) { |