Last active
August 29, 2015 13:58
-
-
Save meeDamian/10410531 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
t = new Transaction() | |
t.start() |
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
class Order | |
start: (callback) -> | |
callback someDataFetchedFromInterwebs |
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
class Transaction | |
@status = "created" | |
@orders = [ | |
new Order() | |
new Order() | |
new Order() | |
] | |
start: -> | |
console.log "starting transaction!" | |
stupidName = (i=0) => @orders[i].start callback i | |
callback = (i) => (data) => | |
console.log i, data | |
if @orders[ ++i ]? | |
@status = "order_" + i | |
stupidName i | |
else | |
@status = "done" | |
console.log "END" | |
console.log "RUN" | |
stupidName() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment