Skip to main content

api.detach()

Description

Allows removing/detaching action handlers

Usage

api.detach(tag: number | string ): void;

Parameters

  • tag - the name of the action tag

Example

In the example below we add an object with the tag property to the api.on() and api.intercept() handlers, and then we use the api.detach() method to stop logging the actions.

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

let api;

$: if (api) {
api.on(
"select-file",
({ id }) => {
console.log("Selected: " + id);
},
{ tag: "track" }
);

api.on(
"set-path",
({ id }) => {
console.log("Path: " + id);
},
{ tag: "track" }
);
}

function stop() {
api.detach("track");
}

</script>

<button on:click={stop}> Stop logging </button>
<Filemanager bind:api data={getData()} drive={getDrive()} />

Related articles: