README.md in koine-event_manager-1.0.0 vs README.md in koine-event_manager-1.1
- old
+ new
@@ -81,9 +81,41 @@
```ruby
event_manager.trigger(UserSignedIn.new(some_user))
```
+## Adding event manager awareness to your classes
+
+**CAUTION**: This make use of the singleton instance of event manager.
+Singletons are usually a bad idea, so prefer dependency injection over
+singleton instances.
+
+```ruby
+require "koine/event_manager/event_manager_aware"
+
+class MyModel
+ include Koine::EventManager::EventManagerAware
+
+ def some_method
+ event_manager.trigger(SomeEvent.new(foo: :bar))
+ end
+end
+```
+
+The above is the same as:
+
+```ruby
+class MyModel
+ def some_method
+ event_manager.trigger(SomeEvent.new(foo: :bar))
+ end
+
+ def event_manager
+ Koine::EventManager::EventManager.instance
+ end
+end
+```
+
## 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.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).