besked
besked
Event System for notifications similar to ActiveSupport Instrumentation.
Installation
Add this to your application's shard.yml
:
dependencies:
besked:
github: ragmaanir/besked
Usage
require "besked"
class MyPub
include Besked::Publisher(Int32)
end
class MySub
include Besked::Subscriber(Int32)
getter? received : Bool
getter events : Array(Int32)
def initialize
@received = false
@events = [] of Int32
end
def receive(event : Int32)
@received = true
@events << event
end
end
test "local publishers and subscribers" do
pub = MyPub.new
sub = MySub.new
pub.subscribe(sub)
assert !sub.received?
pub.publish(1337)
assert sub.received?
assert sub.events == [1337]
end
Repository
besked
Owner
Statistic
- 1
- 0
- 0
- 1
- 2
- almost 8 years ago
- November 1, 2015
License
MIT License
Links
Synced at
Fri, 08 Nov 2024 06:51:07 GMT
Languages