README.md in angelo-0.1.3 vs README.md in angelo-0.1.4

- old
+ new

@@ -7,11 +7,12 @@ ### Notes/Features * "easy" websocket support via `socket '/path' do |s|` route handler * "easy" websocket stashing via `websockets` helper -* no rack/rack-style params +* "easy" event handling via `async` helpers +* no rack * optional tilt/erb support * optional mustermann support Lots of work left to do! @@ -22,10 +23,13 @@ class Foo < Angelo::Base TEST = {foo: "bar", baz: 123, bat: false}.to_json + HEART = '<3' + @@hearting = false + def pong; 'pong'; end def foo; params[:foo]; end get '/ping' do pong @@ -44,11 +48,11 @@ params.to_json end socket '/ws' do |ws| websockets[:emit_test] << ws - while msg = ws.read + ws.on_message do |msg| 5.times { ws.write TEST } ws.write foo.to_json end end @@ -56,9 +60,27 @@ websockets[:other].each {|ws| ws.write TEST} end socket '/other/ws' do |ws| websockets[:other] << ws + end + + socket '/hearts' do |ws| + + # this is a call to Base#async, actually calling + # the reactor to start the task + # + async :hearts unless @@hearting + + websockets[:hearts] << ws + end + + # this is a call to Base.async, defining the task + # to perform on the reactor + # + async :hearts do + @@hearting = true + every(10){ websockets[:hearts].each {|ws| ws.write HEART } } end end Foo.run