View Source LiveQuery.Query.Def behaviour (LiveQuery v0.3.1)

This module defines the LiveQuery.Query.Def behaviour and struct. The behaviour can be used to make a module-base query definition. The struct can be used as a query definition itself.

Summary

Functions

Just adds the LiveQuery.Query.Def behaviour to your module for you. Modules which implement this behaviour can be used as a query definition.

Creates a new LiveQuery.Query.Def struct which implements the LiveQuery.Query.DefLike protocol.

Types

@type data() :: any()
@type t() :: %LiveQuery.Query.Def{
  handle_call:
    (msg :: any(),
     from :: GenServer.from(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       {:noreply, data()} | {:reply, any(), data()})
    | nil,
  handle_cast:
    (msg :: any(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       data())
    | nil,
  handle_info:
    (msg :: any(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       data())
    | nil,
  init: (state :: %{key: any(), config: map()} -> data())
}

Callbacks

Link to this callback

handle_call(msg, from, state)

View Source (optional)
@callback handle_call(
  msg :: any(),
  from :: GenServer.from(),
  state :: %{:key => any(), :config => map(), optional(:data) => data()}
) :: {:noreply, data()} | {:reply, any(), data()}
Link to this callback

handle_cast(msg, state)

View Source (optional)
@callback handle_cast(
  msg :: any(),
  state :: %{:key => any(), :config => map(), optional(:data) => data()}
) :: data()
Link to this callback

handle_info(msg, state)

View Source (optional)
@callback handle_info(
  msg :: any(),
  state :: %{:key => any(), :config => map(), optional(:data) => data()}
) :: data()
@callback init(state :: %{key: any(), config: map()}) :: data()

Functions

Link to this macro

__using__(opts)

View Source (macro)

Just adds the LiveQuery.Query.Def behaviour to your module for you. Modules which implement this behaviour can be used as a query definition.

@spec new(%{
  :init => (state :: %{key: any(), config: map()} -> data()),
  optional(:handle_call) =>
    (msg :: any(),
     from :: GenServer.from(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       {:noreply, data()} | {:reply, any(), data()}),
  optional(:handle_cast) =>
    (msg :: any(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       data()),
  optional(:handle_info) =>
    (msg :: any(),
     state :: %{:key => any(), :config => map(), optional(:data) => data()} ->
       data())
}) :: t()

Creates a new LiveQuery.Query.Def struct which implements the LiveQuery.Query.DefLike protocol.