grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes in configuration API

grych opened this issue · comments

Make Drab working with multiple apps and endpoints. This API will be included in v0.9.0. There will be no soft depreciation, but will show descriptive compile-time error.

Runtime config

Most of the config options are going to move behind the Endpoint

config :drab, MyAppWeb.Endpoint, 
  otp_app: :my_app, 
  socket: "/drab/socket",
  ...

Endpoint and otp_app are mandatory.

Compile time config

config :drab, phoenix_channel_options: []
config :drab, presence: false
config :drab, default_encoder: Drab.Coder.Cipher

Depreciated

:main_phoenix_app, :pubsub and :endpoint are not longer used

Changes in presence config

config :drab, :presence, id: [session: :current_user_id], endpoint: MyAppWeb.Endpoint
config :drab, :presence, id: [store: :current_user_id], endpoint: MyAppWeb.Endpoint
config :drab, :presence, module: MyApp.MyPresence

To allow custom multiple presence modules:

config :drab, :presence, modules: [MyApp.MyPresence, MyApp.MyPresence2]

Which endpoint to use?

There is the Only One

Determined from the only one endpoint.

In mix drab.install

Found in mix.exs and config.exs of current working dir. Only one endpoint allowed in installer.

Broadcasting

Broadcasting to the binary topic requires endpoint. In case it is the only one, just do it, but in case of multiple topics raise an error and enforce to choose, either by:

  • using tuple {endpoint, topic}
broadcast_js same_topic(MyAppWeb.Endpoint, "topic"), ...

Closed with v0.9.0