Created
December 25, 2016 04:55
-
-
Save hackervera/fbdf093cf2d716159dbf7b332dd28f61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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