constructor: (options = {}) -> super # Set active state whenever someone # goes to a specific post State.change('post', @setPost) @render() # ... sidebar/post_list.module.coffee
do |out| streams << out out.callback { streams.delete(out) } end end post '/publish' do streams.each do |out| out << "data: #{params[:msg]}\n\n" end 204 end SSE example
get '/' do erb :stream end __END__ @@ stream <pre id="log"> </pre> <script> var es = new EventSource('/subscribe/tick'); es.onmessage = function(e) { log.innerHTML += "\n" + e.data }; </script> Tick example