Copyright © 2009-2017 Marc Worrell
Behaviours: gen_server.
Authors: Marc Worrell (marc@worrell.nl).
await/4 | Subscribe once to a notification, detach after receiving the notification. |
await_exact/4 | |
code_change/3 | Convert process state when code is changed. |
detach/3 | Unsubscribe an owner-pid from an event. |
detach_all/2 | Detach all observers for the owner. |
first/4 | Call all observers till one returns something else than undefined. |
foldl/5 | Do a fold over all observers, prio 1 observers first. |
foldr/5 | Do a fold over all observers, prio 1 observers last. |
get_observers/1 | Return all observers. |
get_observers/2 | Return all observers for a particular event. |
handle_call/3 | Add an observer to an event. |
handle_cast/2 | Trap unknown casts. |
handle_info/2 | Handling all non call/cast messages. |
init/1 | Initiates the server, creates a new observer list. |
map/4 | Call all observers, return the list of answers. |
notify1/4 | Cast the event to the first observer. |
notify_async/4 | Cast the event to all observers. |
notify_observer/4 | Notify an observer of an event. |
notify_sync/4 | Cast the event to all observers. |
observe/5 | Subscribe to an event. |
start_link/1 | Starts the notification server. |
start_tests/0 | Start a notifier server for unit testing. |
terminate/2 |
await(Notifier::zotonic_notifier:notifier(), Event::zotonic_notifier:event(), Msg::atom() | tuple(), Timeout::pos_integer()) -> {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}
Subscribe once to a notification, detach after receiving the notification.
await_exact(Notifier::zotonic_notifier:notifier(), Event::zotonic_notifier:event(), Msg::term(), Timeout::pos_integer()) -> {ok, term()} | {ok, {pid(), reference()}, term()} | {error, timeout}
code_change(OldVsn::term(), State::#state{name = atom(), observers = ets:tab(), monitors = map(), pid2event = map()}, Extra::term()) -> {ok, #state{name = atom(), observers = ets:tab(), monitors = map(), pid2event = map()}}
Convert process state when code is changed
detach(Notifier::zotonic_notifier:notifier(), Event::zotonic_notifier:event(), OwnerPid::pid()) -> ok | {error, term()}
Unsubscribe an owner-pid from an event.
detach_all(Notifier::zotonic_notifier:notifier(), OwnerPid::pid()) -> ok | {error, term()}
Detach all observers for the owner
first(Notifier, Event, Msg, ContextArg) -> any()
Call all observers till one returns something else than undefined. The prototype of the observer is: f(Msg, Context)
foldl(Notifier, Event, Msg, Acc0, ContextArg) -> any()
Do a fold over all observers, prio 1 observers first. The prototype of the observer is: f(Msg, Acc, ContextArg)
foldr(Notifier, Event, Msg, Acc0, ContextArg) -> any()
Do a fold over all observers, prio 1 observers last
get_observers(Notifier::zotonic_notifier:notifier()) -> list()
Return all observers
get_observers(Notifier::zotonic_notifier:notifier(), Event::zotonic_notifier:event()) -> list()
Return all observers for a particular event
handle_call(Message, From, State) -> any()
Add an observer to an event
handle_cast(Message, State) -> any()
Trap unknown casts
handle_info(Info, State) -> any()
Handling all non call/cast messages
init(Name::atom()) -> {ok, #state{name = atom(), observers = ets:tab(), monitors = map(), pid2event = map()}}
Initiates the server, creates a new observer list
map(Notifier, Event, Msg, ContextArg) -> any()
Call all observers, return the list of answers. The prototype of the observer is: f(Msg, ContextArg)
notify1(Notifier, Event, Msg, ContextArg) -> any()
Cast the event to the first observer. The prototype of the observer is: f(Msg, Context) -> void
notify_async(Notifier, Event, Msg, ContextArg) -> any()
Cast the event to all observers. The prototype of the observer is: f(Msg, Context) -> void
notify_observer(Msg, X2, IsCall, ContextArg) -> any()
Notify an observer of an event
notify_sync(Notifier, Event, Msg, ContextArg) -> any()
Cast the event to all observers. The prototype of the observer is: f(Msg, Context) -> void
observe(Notifier::zotonic_notifier:notifier(), Event::zotonic_notifier:event(), Observer::zotonic_notifier:observer(), OwnerPid::pid(), Prio::integer()) -> ok | {error, term()}
Subscribe to an event. Observer is a {M,F} or pid()
start_link(Name::atom()) -> {ok, pid()} | {error, term()}
Starts the notification server
start_tests() -> {ok, pid()} | {error, term()}
Start a notifier server for unit testing
terminate(Reason::term(), State::#state{name = atom(), observers = ets:tab(), monitors = map(), pid2event = map()}) -> ok
Generated by EDoc