Module z_notifier

Simple implementation of an observer/notifier.

Copyright © 2009-2017 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Simple implementation of an observer/notifier. Relays events to observers of that event. Also implements map and fold operations over the observers.

Function Index

await/2Subscribe once to a notification, detach after receiving the notification.
await/3
await_exact/2
await_exact/3
detach/2Unsubscribe from an event.
detach/3
detach_all/1Detach all observers and delete the event.
detach_all/2
first/2Call all observers till one returns something else than undefined.
foldl/3Do a fold over all observers, prio 1 observers first.
foldr/3Do a fold over all observers, prio 1 observers last.
get_observers/1List all observers for all events for the site.
get_observers/2Return all observers for a particular event.
map/2Call all observers, return the list of answers.
notify/2Async cast the event to all observers.
notify1/2Async cast the event to the first observer.
notify_queue/1Notify delayed notifications.
notify_queue_flush/1Erase queued notifications.
notify_sync/2Sync cast the event to all observers.
observe/3Subscribe to an event.
observe/4Subscribe to an event.
observe/5

Function Details

await/2

await(Msg::tuple() | atom(), Context::z:context()) -> {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}

Subscribe once to a notification, detach after receiving the notification.

await/3

await(Msg::tuple() | atom(), Timeout::pos_integer(), Context::z:context()) -> {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}

await_exact/2

await_exact(Msg::tuple() | atom(), Context::#context{}) -> {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}

await_exact/3

await_exact(Msg::tuple() | atom(), Timeout::pos_integer(), Context::z:context()) -> {ok, tuple() | atom()} | {ok, {pid(), reference()}, tuple() | atom()} | {error, timeout}

detach/2

detach(Event, Context) -> any()

Unsubscribe from an event.

detach/3

detach(Event, OwnerPid, Site) -> any()

detach_all/1

detach_all(Context) -> any()

Detach all observers and delete the event

detach_all/2

detach_all(OwnerPid, Site) -> any()

first/2

first(Msg, Context) -> any()

Call all observers till one returns something else than undefined. The prototype of the observer is: f(Msg, Context)

foldl/3

foldl(Msg, Acc0, Context) -> any()

Do a fold over all observers, prio 1 observers first. The prototype of the observer is: f(Msg, Acc, Context)

foldr/3

foldr(Msg, Acc0, Context) -> any()

Do a fold over all observers, prio 1 observers last

get_observers/1

get_observers(Context::z:context()) -> [{atom(), [{integer(), zotonic_notifier:observer()}]}]

List all observers for all events for the site.

get_observers/2

get_observers(Event, Site) -> any()

Return all observers for a particular event

map/2

map(Msg, Context) -> any()

Call all observers, return the list of answers. The prototype of the observer is: f(Msg, Context)

notify/2

notify(Msg, Context) -> any()

Async cast the event to all observers. The prototype of the observer is: f(Msg, Context) -> void

notify1/2

notify1(Msg, Context) -> any()

Async cast the event to the first observer. The prototype of the observer is: f(Msg, Context) -> void

notify_queue/1

notify_queue(Context) -> any()

Notify delayed notifications.

notify_queue_flush/1

notify_queue_flush(Context) -> any()

Erase queued notifications

notify_sync/2

notify_sync(Msg, Context) -> any()

Sync cast the event to all observers. The prototype of the observer is: f(Msg, Context) -> void

observe/3

observe(Event, Observer, Context) -> any()

Subscribe to an event. Observer is a MFA or pid()

observe/4

observe(Event, Observer, Priority, Context) -> any()

Subscribe to an event. Observer is a MFA or pid()

observe/5

observe(Event::zotonic_notifier:event(), Observer::zotonic_notifier:observer(), OwnerPid::pid(), Priority::integer(), Site::atom() | z:context()) -> ok | {error, term()}


Generated by EDoc