Declarative callback handler for Dust store events.
Define a subscriber module to react to store changes matching a glob pattern:
defmodule MyApp.PostSubscriber do
use Dust.Subscriber,
store: "myapp/data",
pattern: "posts/*"
@impl true
def handle_event(event) do
# event is a map with :store, :path, :op, :value, etc.
IO.inspect(event, label: "post changed")
:ok
end
endThen register it in your Dust config:
config :my_app, MyApp.Dust,
stores: ["myapp/data"],
subscribers: [MyApp.PostSubscriber]Options
:store(required) - the store name to subscribe to:pattern(required) - glob pattern for matching paths (e.g."posts/*"):max_queue_size- maximum pending events before the subscription is dropped due to backpressure (default:1000)