api.intercept()
Description
Allows intercepting and blocking/modifying actionsUsage
api.intercept(
action: string,
handler: function
): void;
Parameters
action
- (required) an action to be firedhandler
- (required) a handler to be attached (the handler arguments will depend on the event to be fired
info
The full list of the FilterBuilder actions can be found here
Example
The example below shows how to add a rule and block opening the editor form on the add-rule
action:
<script>
import { getData } from "./common/data";
import { FilterBuilder } from "wx-svelte-filter";
const { value, fields, options } = getData();
const init = (api) => {
api.intercept("add-rule", ev => {
ev.edit = false;
ev.rule.includes = ["Daisy"];
});
}
</script>
<FilterBuilder {value} {options} {fields} {init} />
Related articles: