Last active
August 29, 2015 13:56
-
-
Save dagda1/9340726 to your computer and use it in GitHub Desktop.
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 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'}]; | |
return this; | |
}; | |
var iterator = new BulkLoader().iterator() | |
var users = iterator.next(); | |
var contacts = iterator.next(users.value); | |
var companies = iterator.next(contacts.value); | |
var result = iterator.next(companies.value).value; | |
console.log(result.users); | |
console.log(result.contacts); | |
console.log(result.companies); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment