WalEx.Event.Dsl (WalEx v4.8.0)

Copy Markdown View Source

Macros that build the process_all/process_insert/process_update/process_delete callbacks invoked by WalEx.Events.EventModules for each subscribed table.

Used by host applications via use WalEx.Event, name: MyApp. The on_event/2, on_insert/4, on_update/4, and on_delete/4 macros expand into the appropriate process_* functions on the host module.

Summary

Functions

Defines process_delete/1 on the caller for events on name matching filters.

Defines process_all/1 on the caller module.

Defines process_all/1 for a specific table; same shape as on_insert/4 but matches every event type.

Defines process_insert/1 on the caller for events on name matching filters.

Defines process_update/1 on the caller for events on name matching filters.

Fans events out to each function in functions, running them in independent Tasks. Each function may be an atom (a function in the caller's module) or a {Module, function} tuple.

Functions

on_delete(name, filters \\ %{}, functions \\ [], do_block)

(macro)

Defines process_delete/1 on the caller for events on name matching filters.

on_event(atom, do_block)

(macro)

Defines process_all/1 on the caller module.

With :all, the block receives every event in the transaction. With a table name, the block receives only events for that table after applying filters (:unwatched_records, :unwatched_fields) and dispatching to functions.

on_event(name, filters \\ %{}, functions \\ [], do_block)

(macro)

Defines process_all/1 for a specific table; same shape as on_insert/4 but matches every event type.

on_insert(name, filters \\ %{}, functions \\ [], do_block)

(macro)

Defines process_insert/1 on the caller for events on name matching filters.

on_update(name, filters \\ %{}, functions \\ [], do_block)

(macro)

Defines process_update/1 on the caller for events on name matching filters.

process_events_async(events, functions)

(macro)

Fans events out to each function in functions, running them in independent Tasks. Each function may be an atom (a function in the caller's module) or a {Module, function} tuple.