Plushie (Plushie v0.6.0)

Copy Markdown View Source

Native desktop GUIs from Elixir, powered by iced.

Quick start

{:ok, pid} = Plushie.start_link(MyApp)

Dev mode (live code reloading)

# In config/dev.exs:
config :plushie, code_reloader: true

# Or as a start_link option:
{:ok, pid} = Plushie.start_link(MyApp, code_reloader: true)

Under a supervisor

children = [
  {Plushie, app: MyApp}
]

Options

  • :app -- (required) the app module implementing Plushie.App
  • :app_opts -- opts forwarded to app.init/1 (default: [])
  • :binary -- path to the plushie binary (default: auto-resolved)
  • :name -- supervisor registration name (default: Plushie)
  • :daemon -- if true, keep running after the last window closes
                  (default: `false`). In daemon mode, `all_windows_closed`
                  is delivered to `update/2` instead of triggering shutdown.
  • :code_reloader -- enable dev-mode live reloading. false (default),
                  `true`, or a keyword list of reloader options
                  (`:debounce_ms`, `:rebuild_artifacts`). Can also be set
                  via `config :plushie, code_reloader: true`.
  • :transport -- :spawn (default, spawns the renderer as a child
                  process), `:stdio` (reads/writes the BEAM's own
                  stdin/stdout, for use with `plushie --exec`), or
                  `{:iostream, pid}` (custom transport via iostream
                  adapter -- see `Plushie.Bridge` for the protocol)
  • :format -- wire format, :msgpack (default) or :json
  • :log_level -- plushie binary log level (:off, :error, :warning, :info, :debug).
                  Default: `:error`.
  • :renderer_args -- extra CLI args passed to the renderer process

When :transport is :stdio or {:iostream, pid}, the :binary option is ignored (no renderer subprocess is spawned).

Summary

Functions

Returns the registered name of the bridge for the given instance.

Child spec for embedding Plushie under an existing supervisor.

Returns the registered name of the runtime for the given instance.

Starts a Plushie application under a supervisor linked to the calling process.

Stops a running Plushie supervisor.

Functions

bridge_for(instance_name \\ __MODULE__)

@spec bridge_for(instance_name :: atom()) :: atom()

Returns the registered name of the bridge for the given instance.

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Child spec for embedding Plushie under an existing supervisor.

Example

children = [
  {Plushie, app: MyApp, name: :my_app_gui}
]

runtime_for(instance_name \\ __MODULE__)

@spec runtime_for(instance_name :: atom()) :: atom()

Returns the registered name of the runtime for the given instance.

start_link(app_module, opts \\ [])

@spec start_link(
  module(),
  keyword()
) :: Supervisor.on_start()

Starts a Plushie application under a supervisor linked to the calling process.

Returns {:ok, pid} on success.

stop(pid_or_name \\ __MODULE__)

@spec stop(pid() | atom()) :: :ok

Stops a running Plushie supervisor.

Accepts a pid or the instance name passed as :name to start_link/2 (defaults to Plushie, matching the default registration).