View Source WxObject behaviour (wx_ex v0.4.0)

An Elixir wrapper for Erlang’s :wx_object behaviour, inspired by GenServer etc.

Does not yet support 100% of :wx_object’s API. Specifically, handle_sync_event/2 is not yet implemented.

Unlike GenServer, WxObject returns a wxWindow reference rather than a pid. If you want to include your top level object in your supervision tree, you will need to return the pid from start_link. For example:

def start_link(_arg) do
  ref = WxObject.start_link(__MODULE__, nil, name: __MODULE__)
  {:ok, WxObject.get_pid(ref)}
end

Summary

Functions

Make a synchronous call to the server and wait for its reply.

Cast a request to the server without waiting for a response.

Callbacks

Link to this callback

handle_call(request, from, state)

View Source (optional)
@callback handle_call(request :: term(), from :: GenServer.server(), state :: term()) ::
  {:reply, reply, new_state}
  | {:reply, reply, new_state,
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:noreply, new_state}
  | {:noreply, new_state,
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, reason, reply, new_state}
  | {:stop, reason, new_state}
when reply: term(), new_state: term(), reason: term()
Link to this callback

handle_cast(request, state)

View Source (optional)
@callback handle_cast(request :: term(), state :: term()) ::
  {:noreply, new_state}
  | {:noreply, new_state,
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, reason :: term(), new_state}
when new_state: term()
Link to this callback

handle_event(request, state)

View Source
@callback handle_event(
  request ::
    {:wx, id :: integer(), obj :: :wx.wx_object(), userData :: term(),
     event :: tuple()},
  state :: term()
) ::
  {:noreply, new_state :: term()}
  | {:noreply, new_state :: term(), timeout() | :hibernate}
  | {:stop, reason :: term(), new_state :: term()}
Link to this callback

handle_info(msg, state)

View Source (optional)
@callback handle_info(msg :: :timeout | term(), state :: term()) ::
  {:noreply, new_state}
  | {:noreply, new_state,
     timeout() | :hibernate | {:continue, continue_arg :: term()}}
  | {:stop, reason :: term(), new_state}
when new_state: term()
@callback init(args :: term()) ::
  {{:wx_ref, ref :: term(), type :: term(), state :: term()},
   [{:state, term()}]}
  | {{:wx_ref, ref :: term(), type :: term(), state :: term()}, state :: term(),
     timeout() | :hibernate}
  | {:stop, reason :: term()}
  | :ignore

Functions

Link to this function

call(obj, request, timeout \\ 5000)

View Source
@spec call(:wx.wx_object(), term(), timeout()) :: term()

Make a synchronous call to the server and wait for its reply.

@spec cast(:wx.wx_object(), term()) :: term()

Cast a request to the server without waiting for a response.

@spec get_pid(:wx.wx_object() | atom() | pid()) :: pid()

See :wx_object.get_pid/1.

Link to this function

start_link(module, args, options \\ [])

View Source