Skip to main content

api.on()

Description

Allows attaching a handler to the inner events

Usage

api.on(
event: string,
handler: function
): void;

Parameters

  • event - (required) an event to be fired
  • handler - (required) a handler to be attached (the handler arguments will depend on the event to be fired)
info

The full list of the File Manager actions can be found here. Use the api.on() method if you want to listen to the actions without modifying them. To make changes to the actions, apply the api.intercept() method.

Example

<script>
import { getData, getDrive } from "./common/data";
import { Filemanager } from "wx-svelte-filemanager";

let api;

$: if (api) {
api.on("show-preview", ({ mode }) => {
console.log(`Preview is ${mode ? "visible" : "hidden"}`);
});
}
</script>

<Filemanager data={getData()} drive={getDrive()} bind:api />

Related articles: