Basics

Basics of the UI context.

circle-exclamation

What is $ui.register?

You can interact with the user interface and execute business logic via APIs provided to your plugin when you register a UI context.

function init() {
   // This function registers the UI context for your plugin, allowing it to
   // have access to UI APIs
   $ui.register((ctx) => {
      // The 'ctx' objects contains all the APIs
   })
}

Unlike hooks which are called every time a specific event is triggered, the function inside $ui.register is called only once during the lifetime of your plugin, right after init(), in other words, each time your plugin is loaded.

circle-info

You cannot register hook handlers inside the UI callback.

Fetch

circle-info

As of v3.3.0, network requests require you to whitelist domains Network Requests

circle-exclamation

States

State management allows you to keep track of dynamic data within your plugin. This approach not only helps maintain a clear separation of concerns but also enables reactive programming, where UI components like the Tray automatically update in response to changes in states.

Computed

Effects

Example

In this example, we fetch some info from an external API each time the user navigates to an anime page.

Last updated