diff --git a/CHANGELOG.md b/CHANGELOG.md index 046c8ee..3fe1b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## Current +## [1.1.X] - 2018.02.17 ### Added diff --git a/README.md b/README.md index c6c70e3..b57ce6d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The package can be installed by adding `event_bus` to your list of dependencies ```elixir def deps do - [{:event_bus, "~> 1.0.0"}] + [{:event_bus, "~> 1.1"}] end ``` @@ -442,11 +442,13 @@ EventBus optionally allows you to track `:register_topic`, `:unregister_topic`, Note: Enabling optional system events decreases the EventBus performance because it at least doubles the operation calls. It is not recommended to enable these events unless you certainly require to track these events espcially `notify`, `mark_as_completed` and `mark_as_skipped`. -Enabling observable events only can be done on compile time. Thus, you need to add it to your app configuration. Here is sample configuration to subscribe optional system events: +Enabling observable events only can be done on compile time (It's good idea to delete your cached build via `rm -rf _build`). Thus, you need to add it to your app configuration. Here is sample configuration to subscribe optional system events: ```elixir config :event_bus, observables: ~w(register_topic unregister_topic subscribe unsubscribe notify mark_as_completed mark_as_skipped)a, + id_generator: fn -> :base64.encode(:crypto.strong_rand_bytes(8)) end, + #id_generator: fn -> UUID.uuid4() end ... ``` diff --git a/lib/event_bus.ex b/lib/event_bus.ex index 4bcb92c..8d34376 100644 --- a/lib/event_bus.ex +++ b/lib/event_bus.ex @@ -1,5 +1,8 @@ defmodule EventBus do - @moduledoc false + @moduledoc """ + Traceable, extendable and minimalist event bus implementation for Elixir with + built-in event store and event watcher based on ETS + """ use EventBus.EventSource alias EventBus.{Notifier, Store, Watcher, Subscription, Topic} @@ -141,11 +144,9 @@ defmodule EventBus do """ @spec subscribe(tuple()) :: :ok def subscribe({listener, topics}) when is_observable(:subscribe) do - unless Enum.member?(subscribers(), {listener, topics}) do - EventSource.notify sys_params() do - Subscription.subscribe({listener, topics}) - %{action: :subscribe, listener: listener, topics: topics} - end + EventSource.notify sys_params() do + Subscription.subscribe({listener, topics}) + %{action: :subscribe, listener: listener, topics: topics} end :ok @@ -169,13 +170,11 @@ defmodule EventBus do :ok """ - @spec unsubscribe(tuple()) :: :ok - def unsubscribe({listener}) when is_observable(:unsubscribe) do - if Enum.member?(subscribers(), {listener}) do - EventSource.notify sys_params() do - Subscription.unsubscribe({listener}) - %{action: :unsubscribe, listener: listener} - end + @spec unsubscribe({tuple() | module()}) :: :ok + def unsubscribe(listener) when is_observable(:unsubscribe) do + EventSource.notify sys_params() do + Subscription.unsubscribe(listener) + %{action: :unsubscribe, listener: listener} end :ok diff --git a/mix.exs b/mix.exs index e75c28c..494ae1c 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule EventBus.Mixfile do def project do [ app: :event_bus, - version: "1.0.0", + version: "1.1.2", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), build_embedded: Mix.env() == :prod,