Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul dagda1

View GitHub Profile
View whatwewant.js
try {
var users = getJSON('/users');
var companies = getJSON('/companies');
var contacts = getJSON('/contacts');
return [users, companies, contacts];
} cacth (e) {
//handler error
}
View async.js
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;
View standard.js
try {
var users = getJSON('/users');
var companies = getJSON('/companies');
var contacts = getJSON('/contacts');
return [users, companies, contacts];
} cacth (e) {
//handler error
}
View callback.js
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;
View bs.js
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;
View bel.js
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;
View prom.js
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')
View ast.js
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;
View one.js
function * oneToThree() {
yield 1;
yield 2;
yield 3;
}
var iterator = oneToThree(),
obj = {};
while(!obj.done) {
View bs2.js
function BulkLoader(){
this.users = [];
this.companies = [];
this.contacts = [];
};
BulkLoader.prototype.iterator = function * () {
this.users = yield [{name: 'bob', email: 'bob@hotmail.com'}];
this.contacts = yield [{name: 'brian', email: 'brian@hotmail.com'}];
this.companies = yield [{name: 'company', email: 'company@hotmail.com'}];
You can’t perform that action at this time.