Skip to content

Instantly share code, notes, and snippets.

@uzulla
Created August 18, 2013 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzulla/6261262 to your computer and use it in GitHub Desktop.
Save uzulla/6261262 to your computer and use it in GitHub Desktop.
Coffee scriptでかいた、非同期処理で使うための簡単なライブラリ。 Web SQLのライブラリをCoffeeScriptで書くのに必要だったので書きました、もう使ってない。
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