Created
August 18, 2013 11:47
-
-
Save uzulla/6261262 to your computer and use it in GitHub Desktop.
Coffee scriptでかいた、非同期処理で使うための簡単なライブラリ。
Web SQLのライブラリをCoffeeScriptで書くのに必要だったので書きました、もう使ってない。
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 myChain | |
func_queue: [] | |
index: -1 | |
chain: (func) -> | |
@func_queue.push(func) | |
return @ | |
chainExec: () -> | |
@index++ | |
@func_queue[@index]?.apply(this, arguments); | |
#--- test | |
console.log "chain test" | |
c = new myChain | |
var0 = 'すがわらさんありがとう' | |
c.chain( (c,var0)-> | |
console.log var0 | |
console.log 1 | |
setTimeout( | |
() -> | |
c.chainExec(c) | |
3000 | |
) | |
).chain( (c)-> | |
console.log 2 | |
val1 = 'hello hello' | |
c.chainExec(c , val1) | |
).chain( (c, val1)-> | |
console.log 3 | |
console.log val1 | |
c.chainExec(c) #あってもなくてもOK | |
).chainExec(c,var0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment