Drab v0.8.3 Release Notes
Release Date: 2018-06-22 // almost 6 years ago-
This version brings two useful features: presence and ability to subscribe to topics in the runtime.
⬆️ Upgrading from =< 0.8.2
Please ensure you have set
:main_phoenix_app
in yourconfig.exs
. The way how Drab is searching
for the Phoenix app it is working on, has been changed.Subscribe and unsubscribe from external topics in a runtime
Finally, you are not limited to the compile-time topic you’ve set with
broadcasting/1
macro in the
commander. Now you cansubscribe/2
to the external topic, receiving broadcasts sent to it.subscribe(socket, same\_action(MyApp.MyController, :index))subscribe(socket, same\_topic("user\_#{user\_id}"))
Presence
Conveniences for Phoenix.Presence
🔧 If configured (it is disabled by default), tracks the user presence on the topic. The following
example shows the number of connected users, live:defmodule MyAppWeb.MyCommander use Drab.Commander broadcasting "global" onconnect :connected ondisconnect :disconnected def connected(socket) do broadcast\_html socket, "#number\_of\_users", Drab.Presence.count\_users(socket) enddef disconnected(\_store, \_session) do topic = same\_topic("global") broadcast\_html topic, "#number\_of\_users", Drab.Presence.count\_users(topic) endend
0️⃣ By default, presence map key is set as a browser UUID (which is shamelessly stored in the local
💻 store in the browser), but it may be also any session value. This may be useful, if you have the
🔧user_id
already in the session, just configure it:config :drab, :presence, id: :user\_id
⚡️ Updated enable/disable when processing behaviour
After launching an event from the page, the control (button) is disable until processing stops.
👍 Now it is even better, as it recognizes previously disabled controls (#146).