The news in the app's LiveViews: an on_mount hook that gives each
LiveView of a live_session the @tayori assign, for the components of
Tayori.Components.
live_session :app,
on_mount: [
{MyAppWeb.UserAuth, :ensure_authenticated},
{Tayori.Live, resolver: MyAppWeb.TayoriResolver, page: "/changelog"}
] do
...
endPut it after the app's own hooks: the resolver reads the reader from
the socket's assigns (Tayori.Resolver.resolve_reader/1).
Options:
:resolver- the app'sTayori.Resolver(required). A module alone,{Tayori.Live, MyAppWeb.TayoriResolver}, is the resolver.:page- the path of the public page (Tayori.Router.tayori_page/2), for the panel's link to all the news.:limit- the entries of the panel, and of each "Show more" (10).
@tayori holds the reader, the number of entries they have not seen
(@tayori.unread), and, once the panel is open, its entries. It stays
live: an entry published, scheduled or changed in the admin reaches
every open page as it happens, and seeing the news in one tab clears
the count in the others.
The events tayori:open, tayori:close and tayori:more open the
panel (and mark the news as seen), close it, and load more; the
components send them, and a LiveView's own button can too
(phx-click="tayori:open"). The hook handles them, and the messages of
the PubSub, before the LiveView sees them.