Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class AsyncApp
# This is a template async response. N.B. Can't use string for body on 1.9
AsyncResponse = [-1, {}, []].freeze
def call(env)
body = DeferrableBody.new
EventMachine::next_tick { env['async.callback'].call [200, {'Content-Type' => 'text/plain'}, body] }
EventMachine::add_periodic_timer(3) do
EventMachine::next_tick { body.call ["Cheers then!"] }
# body.succeed
end
AsyncResponse
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment