HomeDash.Provider behaviour (home_dash v0.0.1)

Defines a homedash provider.

A homedash provider is responsible for sending cards and card updates to subscribers.

use HomeDash.Provider

Overridable

def handle_cards(msg, opts) do
  {:ok, fetch_cards()}
end

Summary

Types

Link to this type

component_id()

@type component_id() :: String.t()
Link to this type

handle_cards_response()

@type handle_cards_response() ::
  {:ok, [HomeDash.Card.t()]}
  | {:new, [HomeDash.Card.t()]}
  | {:delete, [HomeDash.Card.t() | String.t()]}
  | {:error, any()}
@type opts() :: term()
@type state() :: %{
  opts: opts(),
  cards: %{required(String.t()) => HomeDash.Card.t()},
  subscriptions: [subscription()]
}
Link to this type

subscription()

@type subscription() :: {pid(), component_id()}

Callbacks

Link to this callback

handle_cards(term, opts)

(optional)
@callback handle_cards(term(), opts()) :: handle_cards_response()
Link to this callback

push_cards(t, pid)

@callback push_cards(HomeDash.Card.t(), pid()) :: :ok
Link to this callback

remove_cards(t, pid)

@callback remove_cards(HomeDash.Card.t(), pid()) :: :ok
Link to this callback

set_cards(t, pid)

@callback set_cards(HomeDash.Card.t(), pid()) :: :ok
Link to this callback

start_link(keyword)

@callback start_link(keyword()) :: GenServer.on_start()
Link to this callback

subscribe(keyword, pid, term)

@callback subscribe(keyword(), pid(), term()) :: :ok

Functions

Link to this macro

handle_info_home_dash()

(macro)