ExperimentalExperimental
Send one request to the player by its method name and get its answer.
The player's method name ("ui.setMount").
Optionalparams: Json
Its parameters, a JSON object (omitted: none).
The player's result, once the player answered.
Experimental: the wire protocol is not semver; this member changes with
versions. method and params go to the player as given; the answer is
the player's result, typed by the caller (T). The player's refusals
arrive with their own codes (invalid, missing, stale…).
Nothing of the SDK's sits between: no value limits, no seq or
revision, no retry after a lost reply, no wait during activation. A
request that changes something the SDK keeps (a window the SDK opened,
a command added with Commands.add) leaves the SDK's copy out of
date. The subscriptions are guarded. For the events the SDK knows
(HostEvent) events.subscribe and events.unsubscribe are
refused: the player keeps one subscription per event name, with one
mark, and the SDK owns those (its copies of the state,
Player.on); listen with Wire.on and stop by disposing
what it returned. For any other event (a newer player's)
events.subscribe must say why the plugin listens, why (a list of
reasons for the player's log) or mirror: true (only a copy of the
state), so the player's decision to keep the plugin running is never
fooled; the SDK does not count such a subscription, the plugin
unsubscribes it itself.
invalid (throws) method is not a non-empty string, it is
events.subscribe or events.unsubscribe of a HostEvent,
or events.subscribe of another event without why (a non-empty
list of strings) or mirror: true.
The plugin's adjust tab shows "1.00×" in its rate property, written
with the player's own request. The parameters are the protocol's
(property, value); the player checks the value.
const panel = plugin.panels.mount("adjust", "ui/speed.slint", { title: "Speed" });
await panel.ready;
await plugin.wire.request("ui.setMount", { property: "rate", value: "1.00×" });
Experimental
Listen to one event of the player by its name, with its data as the player sent it, untyped.
The event's name.
Receives each event's data.
A handle that stops listening; it is disposed with the scope.
Experimental: the wire protocol is not semver; this member changes
with versions. For one of the HostEvent names the SDK subscribes
(events.subscribe) as for Player.on: once per name however
many listeners, always marked as a listener with where it was added
(why), never as a copy of the state (mirror), so the player keeps
the plugin running while it listens (unless the player wakes a
stopped plugin for that event). Any other name is listened
to without a subscription: events the player sends unasked
(commands.execute, ui.callback, ui.closed), or an event of a newer
player that the plugin subscribed to itself with Wire.request.
The listener gets a copy of the data, typed unknown: the plugin
checks its shape (Player.on types it for the known events). As
for Player.on, no update pass follows the listener, and its errors
go to Scope.onError.
The listener hears the player's commands.execute event, which the
player sends unasked when the user picks one of this plugin's commands.
Its data names the command by its local id; the SDK still runs the
command's own run too.
plugin.wire.on("commands.execute", (data) => {
const { id } = data as { id: string };
console.log(`the player ran ${id}`);
});
Experimental
Write a view's properties directly, below the SDK's comparison and row patches.
A window, panel or settings page this plugin made.
The view's direct writes.
Experimental: the wire protocol is not semver; this member changes
with versions. view is a Window, Panel or
SettingsPage of this plugin; the writes go to it as
ui.set, ui.setMount or settings.set. See WireView.
The sidebar shows a list the plugin keeps itself. The first write sends the whole list; later changes are row operations on what the player shows, sent as they are.
const side = plugin.panels.mount("sidebar", "ui/list.slint");
await side.ready;
const rows = plugin.wire.view(side);
await rows.write("items", { value: [{ id: "a", label: "First" }] });
await rows.writeRows("items", [{ op: "insert", at: 1, rows: [{ id: "b", label: "Second" }] }]);
Direct messages to the player (
plugin.wire): requests by method name, raw events, property writes below the SDK's comparison and bare command registrations. Experimental: the wire protocol is not semver; this member changes with versions.Remarks
The plugin API wraps the player's protocol (JSON requests and events over the plugin's standard input and output) in typed members that keep state, compare values and recover from lost replies.
plugin.wireis the layer below them, for trying a player method the SDK does not wrap yet, or for a plugin that wants to send exactly what it chooses. Prefer the typed members: they are semver,plugin.wireis not. A method or event can change or disappear with a player version, and members ofplugin.wiremay change in any SDK release without a deprecation period.What the SDK still does at this level:
onmarks its subscription as a listener with where it was added (so the player keeps the plugin running and names the listener in its log),view(v)sends one write per property at a time and splits large ones, andcommands.registerwaits during activation likecommands.add. What it leaves to the plugin: the parameters' shape, the value limits, revisions ofrequest, retries.The Tutorial shows
bind()(the default), Player.on with View.set, andplugin.wireside by side, from examples/three-ways; the method and event names are in Messages and Events.Example: Show the speed with direct messages
A tab in the adjust column shows the playback speed, written by the plugin itself from the raw
source.stateevent. The listener types the payload, which isunknownhere, andview(panel).writesends the text as a property write; the SDK keeps no copy of the state and compares nothing.Since
1.7.0