Documentation
¶
Overview ¶
Package plugin calls native code: a method of a plugin registered in the iOS or Android host, written in Swift or Kotlin. Arguments and results travel as JSON, so a plugin needs no generated code on either side.
type token struct{ Value string `json:"value"` }
t, err := plugin.Call[token](ctx, "secureStorage", "get", map[string]string{"key": "token"})
Call blocks until the native side answers, so call it where blocking is fine: in ui.UseQuery, ui.UseAction, an effect or your own goroutine, not in Render. The host runs every plugin method on its main thread.
Plugins are registered in the host:
Plugins.register("battery") { call in call.resolve(UIDevice.current.batteryLevel) } // Swift
Plugins.register("battery") { call -> call.resolve(level) } // Kotlin
Index ¶
Constants ¶
const ( Cancelled = "cancelled" Denied = "denied" NotFound = "not_found" Failed = "failed" )
Codes of Error.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
Call runs method on the named plugin with args (any JSON-encodable value, or nil) and decodes the answer into Resp. Use struct{} or any for a method with no useful answer.
func Deliver ¶
func Deliver(r *render.PluginResult)
Deliver hands a plugin's outcome to the waiting Call. The UI runtime calls it for every PluginResult the host sends.