MobAsh.Refresh (mob_ash v0.1.2)

Copy Markdown View Source

Per-resource pubsub for :mob_ash_refresh messages. Screens showing a list of records subscribe; screens that mutate records dispatch. The underlying Registry is started by MobAsh.Application.

See MOB-56 — before this module the ListScreen's handle_info(:mob_ash_refresh, ...) clause existed but nothing ever sent it, so lists stayed stale after a create/delete pop-back.

Summary

Functions

Send :mob_ash_refresh to every process subscribed to resource.

Subscribe the calling process to refresh events for resource.

Functions

broadcast(resource)

@spec broadcast(module()) :: :ok

Send :mob_ash_refresh to every process subscribed to resource.

subscribe(resource)

@spec subscribe(module()) :: :ok

Subscribe the calling process to refresh events for resource.

Idempotent: the Registry uses keys: :duplicate, so this checks the caller's existing keys and registers only once per resource. ListScreen.load/2 calls it on mount and on every refresh, so without the check each broadcast would double the caller's registrations (MOB-296). Entries are dropped when the subscribing process exits.