new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Tauri · Plugins and security · all subjects

core plugin api

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Android argument definition patterns

In Android plugin argument classes: Optional arguments are defined as `var <argumentName>: Type? = null`. Arguments with default values are defined as `var <argumentName>: Type = <default-value>`. Required arguments are defined as `lateinit var <argumentName>: Type`.

iOS command argument parsing with Decodable

Arguments are serialized to commands and can be parsed on the iOS plugin with the `invoke.parseArgs(Type.self)` function. Define argument classes that inherit `Decodable`. Inner objects must also inherit the Decodable protocol.

Android command with @Command annotation

To add mobile commands in Android, annotate a method with `@Command` inside the plugin class. The method receives an `Invoke` parameter. Return results by calling `invoke.resolve(ret)` with a JSObject containing the result.

Android suspend function with custom coroutine scope

To use a Kotlin suspend function in Android plugin commands, create a custom coroutine scope using `CoroutineScope(Dispatchers.Default + SupervisorJob())` and launch the suspend function within it. Use `Dispatchers.IO` instead of `Dispatchers.Default` if the function is intended for fetching data.

Android long-running operations must avoid main thread

On Android native commands are scheduled on the main thread. Performing long-running operations will cause the UI to freeze and potentially 'Application Not Responding' (ANR) error. If you need to wait for some blocking IO, launch a coroutine with `CoroutineScope(Dispatchers.IO).launch` to execute the operation asynchronously.

iOS command implementation

To add mobile commands in iOS, annotate a method with `@objc` inside the plugin class that extends Plugin. The method receives an `Invoke` parameter and can throw errors. Return results by calling `invoke.resolve([key: value])` with a dictionary containing the result.

Android command argument parsing with @InvokeArg

Arguments are serialized to commands and can be parsed on the Android plugin with the `Invoke::parseArgs` function, taking a class describing the argument object. Define argument classes annotated with `@app.tauri.annotation.InvokeArg`. Inner objects must also be annotated.

iOS argument definition patterns

In iOS plugin argument classes: Optional arguments are defined as `var <argumentName>: Type?`. Arguments with default values are NOT supported; use a nullable type and set the default value on the command function instead. Required arguments are defined as `let <argumentName>: Type`.

Plugin events with trigger function

Plugins can emit events at any point in time using the `trigger` function. For Android, call `trigger("eventName", JSObject())` with an event name and payload object. For iOS, call `trigger("eventName", data: [key: value])` with an event name and payload dictionary.

Give your agent this brain