Skip to content

Breaking Release

Choose a tag to compare
@grych grych released this 29 Jun 21:45
· 96 commits to master since this release

This release finally introduces the final API. There is no intention to change it, unless very
significant errors are found.

If you are using Drab already, prepare for the changes in the configuration and also in the code.

Drab.Live API changed

As described in #127, API has changed. The most painful change is Drab.Live.peek, as it now
returns {:ok, value} or {:error, why}. Raising Drab.Live.peek is for convinience.

Drab.Live.poke returns tuple now as well, to catch update errors or disconnections.

Redesigned Drab.Config

Since this version, Drab is no longer configured globally. This means that you may use it in the
multiple endpoints environments.
This requires configuration API change. Most of the Drab options are now located under
the endpoint module:

config :drab, MyAppWeb.Endpoint,
  otp_app: :my_app_web,

The endpoint and application name are mandatory.

However, there are still few global options, like :enable_live_scripts. Please read
Drab.Config documentation
for more information.

Do You Want to Know More?

More API changes

All functions returning {:timeout, description} now return just {:error, :timeout}.

Undeclared handler or shared commander raises

All handlers must now be strictly declared by using Drab.Commander.defhandler or
Drab.Commander.public macro.

defhandler my_handler(socket, payload), do: ..


public :my_handler
def my_handler(socket, payload), do: ...

The same is with shared commanders, if you want to use it, declare it with Drab.Controller:

use Drab.Controller, commanders: [My.Shared.Commander]

Hard depreciations of various functions

  • Drab.Client.js/2
  • Drab.run_handler()
  • Drab.Browser.console!/2
  • Drab.Browser.redirect_to!/2
  • Drab.Core.broadcast_js!/2

drab-event and drab-handler combination no longer exists

The existing syntax drab-event and drab-handler is removed. Please use the new syntax of:

<tag drab="event:handler">
<input drab="focus:input_focus blur:input_blur"
<input drab-focus="input_focus" drab-blur="input_blur">

Do You Want to Know More?

Updating from <= v0.8.3



config :drab, main_phoenix_app: :my_app_web, endpoint: MyAppWeb.Endpoint


config :drab, MyAppWeb.Endpoint, otp_app: :my_app_web

Most of the configuration options now must be placed under the endpoint. Please read
Drab.Config documentation for more info.