Packages
event_bus
0.1.0
1.7.0
1.6.2
1.6.1
1.6.0
retired
1.5.2
retired
1.5.1
retired
1.5.0
retired
1.4.4
retired
1.4.3
retired
1.4.2
retired
1.4.1
retired
1.4.0
retired
1.3.8
retired
1.3.7
retired
1.3.6
retired
1.3.5
retired
1.3.4
retired
1.3.3
retired
1.3.2
retired
1.3.1
retired
1.3.0
retired
1.2.0
retired
1.1.3
retired
1.1.2
retired
1.1.1
retired
1.1.0
retired
1.0.0
retired
1.0.0-beta4
retired
1.0.0-beta3
retired
1.0.0-beta2
retired
1.0.0-beta1
retired
0.9.0
retired
0.8.0
retired
0.7.0
retired
0.6.1
retired
0.6.0
retired
0.5.0
retired
0.4.1
retired
0.4.0
retired
0.3.1
retired
0.3.0
retired
0.2.1
retired
0.2.0
retired
0.1.0
retired
Traceable, extendable and minimalist event bus implementation for Elixir with built-in event store and event watcher based on ETS
Retired package: Deprecated
Current section
Files
Jump to
Current section
Files
README.md
# EventBus
[](https://travis-ci.org/mustafaturan/event_bus)
Simple event bus implementation.
## Installation
The package can be installed by adding `event_bus` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:event_bus, "~> 0.1.0"}]
end
```
## Usage
Module docs can be found at [https://hexdocs.pm/event_bus](https://hexdocs.pm/event_bus).
Subscribe to the 'event bus'
```elixir
EventBus.subscribe(MyEventListener)
```
Unsubscribe from the 'event bus'
```elixir
EventBus.unsubscribe(MyEventListener)
```
List subscribers
```elixir
EventBus.subscribers()
```
Notify all subscribers with any type of data
```elixir
EventBus.notify(:hello_received, %{message: "Hello"})
EventBus.notify(:bye_received, [user_id: 1, goal: "exit"])
```
### Sample Listener Implementation
```elixir
defmodule MyEventListener do
...
def process({:hello_received, _event_data} = event) do
GenServer.cast(__MODULE__, event)
end
def process({:bye_received, event_data}) do
# do sth
:ok
end
def process({event_type, event_data}) do
# this one matches all events
:ok
end
...
end
```
## Todo
- [ ] Move event data to ETS and pass key instead of data to listeners
## Contributing
### Issues, Bugs, Documentation, Enhancements
1. Fork the project
2. Make your improvements and write your tests(make sure you covered all the cases).
3. Make a pull request.
## License
MIT