Plushie.Event.SystemEvent (Plushie v0.6.0)

Copy Markdown View Source

System query responses and platform events.

Covers responses to system queries (get_system_info, get_system_theme) as well as recurring platform events like animation frames and OS theme changes.

Fields

  • type - :system_info, :system_theme, :animation_frame, :theme_changed, :all_windows_closed, :image_list, :tree_hash, :find_focused, :diagnostic, :announce, or :error
  • tag - caller-supplied correlation tag from the originating query
  • data - payload; shape depends on event type (e.g. a map of system info fields, a theme name string, a frame timestamp, or a renderer error payload. Native widget command failures decode to Plushie.Event.WidgetCommandError instead.

Pattern matching

def update(model, %SystemEvent{type: :system_info, data: %{"os" => os}}) do
  %{model | platform: os}
end

def update(model, %SystemEvent{type: :theme_changed, data: theme}) do
  %{model | theme: theme}
end

def update(model, %SystemEvent{type: :animation_frame, data: ts}) do
  advance_animation(model, ts)
end

Summary

Types

System event delivered by the renderer.

t()

Types

delivered_t()

@type delivered_t() :: t()

System event delivered by the renderer.

t()

@type t() :: %Plushie.Event.SystemEvent{
  data: map() | String.t() | number() | nil,
  tag: String.t() | nil,
  type:
    :system_info
    | :system_theme
    | :animation_frame
    | :theme_changed
    | :all_windows_closed
    | :image_list
    | :tree_hash
    | :find_focused
    | :announce
    | :diagnostic
    | :error
}