feat: expose CRUD, onboarding, pubsub via web
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
defmodule Localiser.Web.Channels.ParticlesChannel do
|
||||
use Phoenix.Channel
|
||||
|
||||
@impl true
|
||||
def join("particles:" <> tag_id, _params, socket) do
|
||||
Phoenix.PubSub.subscribe(Localiser.PubSub, "particles:#{tag_id}")
|
||||
{:ok, assign(socket, :tag_id, tag_id)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:particles_updated, payload}, socket) do
|
||||
push(socket, "particles_updated", %{
|
||||
tag_id: payload.tag_id,
|
||||
estimate: payload.estimate,
|
||||
particles: payload.particles
|
||||
})
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
def handle_info(_msg, socket), do: {:noreply, socket}
|
||||
end
|
||||
Reference in New Issue
Block a user