Drab and Liveview community oddities

LiveView is actually very similar to Drab with Drab.Live, as I understood.

In the first clock example, the difference is that when you return:

{:ok, assigns(socket, data: :calendar.local_time())}

from the msg handler, and Drab.Live uses function poke with side effect. In this case, with Drab, Chris would write:

poke(socket, data: :calendar.local_time())

The advantage of Drab.Live is that it is not sending the whole page, just a changed part, but as Chris said, it will change in the future.

Also, the phx- event bindings are similar to drab- bindings, the difference is just a semantics - I am using named functions as the event handlers, Chris uses general handle_event, so for his plus/minus example in drab it would look like:

<button drab-click='inc'>+</button>
<button drab-click='dec'>-</button>

defhandler inc(socket, _sender), do: poke(socket, val: peek(val) + 1)

Thus, there is no point to develop Drab anymore, as most of its functionality will be built in the Phoenix.

I might take the part with direct manipulation on the DOM (Drab.Element, Drab.Query), and develop a small library with this functionality.

3 Likes