Skip to content

Instantly share code, notes, and snippets.

@yshavit yshavit/

Last active Dec 19, 2015
What would you like to do?
A solution to the "staircase problem" posed by node.js's reliance on callbacks. See
# In some util class...
handler = (errText, f) ->
(err, rows) ->
if err?
console.log "#{errText}: #{err}"
# And then:
m = myqlPool()
barHandler = handler "Couldn't get a bar", (bars) ->
console.log("Found a bar!", bar) for bar in bars
fizzHandler = handler "Couldn't get fizzes", (fizzes) ->
foos = [ for fizz in fizzes]
for foo in foos
do (foo) ->
m.query selectBar, [foo], barHandler
m.query getFizzes, fizzHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.