README.md in koine-event_manager-1.1 vs README.md in koine-event_manager-2.1
- old
+ new
@@ -1,14 +1,12 @@
# Koine::EventManager
Event manager for ruby.
[![Build Status](https://travis-ci.org/mjacobus/koine-event-manager.svg)](https://travis-ci.org/mjacobus/koine-event-manager)
-[![Code Coverage](https://scrutinizer-ci.com/g/mjacobus/koine-event-manager/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/koine-event-manager/?branch=master)
+[![Coverage Status](https://coveralls.io/repos/github/mjacobus/koine-event-manager/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/koine-event-manager?branch=master)
[![Code Climate](https://codeclimate.com/github/mjacobus/koine-event-manager/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/koine-event-manager)
-[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mjacobus/koine-event-manager/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/koine-event-manager/?branch=master)
-[![Dependency Status](https://gemnasium.com/mjacobus/koine-event-manager.svg)](https://gemnasium.com/mjacobus/koine-event-manager)
[![Gem Version](https://badge.fury.io/rb/koine-event_manager.svg)](https://badge.fury.io/rb/koine-event_manager)
## Installation
Add this line to your application's Gemfile:
@@ -81,39 +79,24 @@
```ruby
event_manager.trigger(UserSignedIn.new(some_user))
```
-## Adding event manager awareness to your classes
+### Subscribers
-**CAUTION**: This make use of the singleton instance of event manager.
-Singletons are usually a bad idea, so prefer dependency injection over
-singleton instances.
+You can add and remove subscribers as follows:
```ruby
-require "koine/event_manager/event_manager_aware"
-
-class MyModel
- include Koine::EventManager::EventManagerAware
-
- def some_method
- event_manager.trigger(SomeEvent.new(foo: :bar))
+class MySubscriber
+ def publish(event)
+ # do something
end
end
-```
-The above is the same as:
+subscriber = MySubscriber.new
-```ruby
-class MyModel
- def some_method
- event_manager.trigger(SomeEvent.new(foo: :bar))
- end
-
- def event_manager
- Koine::EventManager::EventManager.instance
- end
-end
+event_manager.subscribe(subscriber, to: UserListener)
+event_manager.unsubscribe(subscriber, from: UserListener)
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.