Skip to main content

api.intercept()

Description

Allows intercepting and blocking/modifying actions

Usage

api.intercept(
action: string,
callback: function
): void;

Parameters

  • action - (required) an action to be fired
  • callback - (required) a callback to be performed (the callback arguments will depend on the action to be fired)
info

The full list of 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

In the example below we use api.intercept() to hide the default Editor by returning false.

<script>
import { getData } from "./common/data";
import { Gantt } from "@wx/svelte-gantt";

const data = getData();

let api;

$:if (api) {
api.intercept("show-editor", data => {
return false;
});
}

</script>

<Gantt bind:api tasks={data.tasks} />

Related articles: