Skip to content

Instantly share code, notes, and snippets.

@raggi
Created November 16, 2011 03:38
Show Gist options
  • Save raggi/1369169 to your computer and use it in GitHub Desktop.
Save raggi/1369169 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'eventmachine'
get '/' do
stream(:keep_open) do |out|
count = 0
timer = EM.add_periodic_timer(1) do
out << "<p>ohai</p>\n"
count += 1
if count == 10
timer.cancel
out.close
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment