evented alternatives and similar shards
Based on the "Misc" category.
Alternatively, view evented alternatives based on common mentions on social networks and blogs.
Do you think we are missing an alternative of evented or a related project?
A micro library providing Crystal objects with Publish-Subscribe capabilities
- Decouple core business logic from external concerns in Hexagonal style architectures
- Use as an alternative to callbacks and Observers
- Connect objects based on context without permanence
- React to events synchronously
Add this to your application's
dependencies: evented: github: krisleech/evented
Evented::Publisher your objects get
broadcast can be called from within your object whenever you want to
broadcast a significant event.
require "evented" class MyPublisher include Evented::Publisher def call(input) result = do_something(input) broadcast(:something_happened, result) end end
To subscribe an object to receive events include
provide your own
on_event method which will receive 2 arguments, the
require "evented" class MySubscriber include Evented::Subscriber def on_event(event_name, payload) # ... end end
To subscribe the listener to a publisher:
publisher = MyPublisher.new publisher.subscribe(MySubscriber.new) publisher.call("hello")
In the above example the subscriber will have
Automatically run Specs
ls ./**/*.cr | entr crystal spec
- Fork it ( https://github.com/krisleech/evented/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- Kris Leech - creator, maintainer