zotonic_notifier (zotonic_notifier v1.0.0-rc.12)

Extension system using notifications with fold, map and priorities.

Link to this section Summary

Functions

Unsubscribe an owner from an event
Unsubscribe an owner from an event
Detach all observers owned by the pid
Detach all observers owned by the pid
Return the result of the first observer returning something else than 'undefined'. Return 'undefined' if none.
Return the result of the first observer returning something else than 'undefined'. Return 'undefined' if none.
Return the list of all observers for a specific event
Call all observers, return a list of all return values.
Notify the first observer. Pids async, M:F sync.
Notify the first observer. Pids async, M:F sync.
Notify observers async. Start separate process for the notification.
Notify observers async. Start separate process for the notification.
Notify observers. Pids async, M:F sync.
Notify observers. Pids async, M:F sync.
Register an observer pid.
Register an observer with an owner pid.
Register an observer with the default notifier. Higher prio (lower nr) gets called earlier.
Register an observer. Higher prio (lower nr) gets called earlier.

Link to this section Types

-type event() :: term().
-type notifier() :: atom() | pid().
-type observer() :: pid() | {module(), atom()} | {module(), atom(), list()}.

Link to this section Functions

-spec await(atom() | tuple()) ->
         {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}.
Link to this function

await(Event, Msg)

-spec await(term(), atom() | tuple()) ->
         {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}.
Link to this function

await(Event, Msg, Timeout)

-spec await(term(), atom() | tuple(), pos_integer()) ->
         {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}.
Link to this function

await(Notifier, Event, Msg, Timeout)

-spec await(notifier(), term(), atom() | tuple(), pos_integer()) ->
         {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}.
Link to this function

await_exact(Event, Msg)

-spec await_exact(event(), term()) ->
               {ok, term()} | {ok, {pid(), reference()}, term()} | {error, timeout}.
Link to this function

await_exact(Event, Msg, Timeout)

-spec await_exact(event(), term(), pos_integer()) ->
               {ok, term()} | {ok, {pid(), reference()}, term()} | {error, timeout}.
Link to this function

await_exact(Notifier, Event, Msg, Timeout)

-spec await_exact(notifier(), event(), term(), pos_integer()) ->
               {ok, term()} | {ok, {pid(), reference()}, term()} | {error, timeout}.
Link to this function

detach(Event, OwnerPid)

-spec detach(event(), pid()) -> ok | {error, term()}.
Unsubscribe an owner from an event
Link to this function

detach(Notifier, Event, OwnerPid)

-spec detach(notifier(), event(), pid()) -> ok | {error, term()}.
Unsubscribe an owner from an event
Link to this function

detach_all(OwnerPid)

-spec detach_all(pid()) -> ok.
Detach all observers owned by the pid
Link to this function

detach_all(Notifier, OwnerPid)

-spec detach_all(notifier(), pid()) -> ok.
Detach all observers owned by the pid
Link to this function

first(Event, Msg, ContextArg)

-spec first(event(), term(), term()) -> term() | undefined.
Return the result of the first observer returning something else than 'undefined'. Return 'undefined' if none.
Link to this function

first(Notifier, Event, Msg, ContextArg)

-spec first(notifier(), event(), term(), term()) -> term() | undefined.
Return the result of the first observer returning something else than 'undefined'. Return 'undefined' if none.
Link to this function

foldl(Event, Msg, Value, ContextArg)

-spec foldl(event(), term(), term(), term()) -> term().
Link to this function

foldl(Notifier, Event, Msg, Value, ContextArg)

-spec foldl(notifier(), event(), term(), term(), term()) -> term().
Link to this function

foldr(Event, Msg, Value, ContextArg)

-spec foldr(event(), term(), term(), term()) -> term().
Link to this function

foldr(Notifier, Event, Msg, Value, ContextArg)

-spec foldr(notifier(), event(), term(), term(), term()) -> term().
Link to this function

get_observers(Event)

-spec get_observers(event()) -> list().
Return the list of all observers for a specific event
Link to this function

get_observers(Notifier, Event)

-spec get_observers(notifier(), event()) -> list().
Link to this function

map(Event, Msg, ContextArg)

-spec map(event(), term(), term()) -> [term()].
Call all observers, return a list of all return values.
Link to this function

map(Notifier, Event, Msg, ContextArg)

-spec map(notifier(), event(), term(), term()) -> [term()].
Link to this function

notify1(Event, Msg, ContextArg)

-spec notify1(event(), term(), term()) -> ok | {error, term()}.
Notify the first observer. Pids async, M:F sync.
Link to this function

notify1(Notifier, Event, Msg, ContextArg)

-spec notify1(notifier(), event(), term(), term()) -> ok | {error, term()}.
Notify the first observer. Pids async, M:F sync.
Link to this function

notify(Event, Msg, ContextArg)

-spec notify(event(), term(), term()) -> ok | {error, term()}.
Notify observers async. Start separate process for the notification.
Link to this function

notify(Notifier, Event, Msg, ContextArg)

-spec notify(notifier(), event(), term(), term()) -> ok | {error, term()}.
Notify observers async. Start separate process for the notification.
Link to this function

notify_sync(Event, Msg, ContextArg)

-spec notify_sync(event(), term(), term()) -> ok | {error, term()}.
Notify observers. Pids async, M:F sync.
Link to this function

notify_sync(Notifier, Event, Msg, ContextArg)

-spec notify_sync(notifier(), event(), term(), term()) -> ok | {error, term()}.
Notify observers. Pids async, M:F sync.
Link to this function

observe(Event, ObserverPid)

-spec observe(event(), pid()) -> ok | {error, term()}.
Register an observer pid.
Link to this function

observe(Event, Observer, OwnerPid)

-spec observe(event(), observer(), pid()) -> ok | {error, term()}.
Register an observer with an owner pid.
Link to this function

observe(Event, Observer, OwnerPid, Prio)

-spec observe(event(), observer(), pid(), integer()) -> ok | {error, term()}.
Register an observer with the default notifier. Higher prio (lower nr) gets called earlier.
Link to this function

observe(Notifier, Event, Observer, OwnerPid, Prio)

-spec observe(notifier(), event(), observer(), pid(), integer()) -> ok | {error, term()}.
Register an observer. Higher prio (lower nr) gets called earlier.
Link to this function

start(StartType, StartArgs)

Link to this function

start_notifier(Name)

-spec start_notifier(atom()) -> {ok, pid()} | {error, term()}.
Link to this function

stop_notifier(Name)

-spec stop_notifier(atom()) -> ok.