Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created December 25, 2016 04:55
Show Gist options
  • Save hackervera/fbdf093cf2d716159dbf7b332dd28f61 to your computer and use it in GitHub Desktop.
Save hackervera/fbdf093cf2d716159dbf7b332dd28f61 to your computer and use it in GitHub Desktop.
require "./stal/*"
require "kemal"
class Notifier
def initialize
@chan = Channel(String).new
end
def notify(msg = "YOLO")
spawn do
puts "before"
@chan.send(msg)
puts "after"
end
end
def chan
@chan
end
end
module Stal
notifier = Notifier.new
get "/" do
notifier.notify
"OK"
end
spawn do
loop do
# Hang out here in processing stage but return web browser immediately
sleep 5
puts notifier.chan.receive
end
end
Kemal.run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment