api specs
This commit is contained in:
15
phoenix/lib/shooting_event_phx/events.ex
Normal file
15
phoenix/lib/shooting_event_phx/events.ex
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule ShootingEventPhx.Events do
|
||||
@moduledoc false
|
||||
@topic "state_updates"
|
||||
|
||||
def topic, do: @topic
|
||||
|
||||
def subscribe do
|
||||
Phoenix.PubSub.subscribe(ShootingEventPhx.PubSub, @topic)
|
||||
end
|
||||
|
||||
def broadcast do
|
||||
payload = {:state, DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601()}
|
||||
Phoenix.PubSub.broadcast(ShootingEventPhx.PubSub, @topic, payload)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user