Update broadcast_event in Kino.JS.Live guide (#894)

This commit is contained in:
Jonatan Kłosko 2022-01-19 19:39:57 +01:00 committed by GitHub
parent b9b901648c
commit 5c1c61d0f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,11 +145,8 @@ defmodule Kino.Leaflet do
@impl true
def handle_cast({:add_marker, location}, ctx) do
ctx =
ctx
|> broadcast_event("add_marker", location)
|> update(:locations, &[location | &1])
broadcast_event(ctx, "add_marker", location)
ctx = update(ctx, :locations, &[location | &1])
{:noreply, ctx}
end
@ -264,6 +261,7 @@ defmodule Kino.Counter do
defp bump_count(ctx) do
ctx = update(ctx, :count, &(&1 + 1))
broadcast_event(ctx, "update", ctx.assigns.count)
ctx
end
asset "main.js" do