Skip to main content

api.intercept()

Description​

Allows intercepting and blocking/modifying actions

Usage​

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

Parameters​

  • action - (required) an action 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 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:

import { getData } from "./common/data";
import { FilterBuilder } from "@svar-ui/react-filter";

const { value, fields, options } = getData();

const MyComponent = () => {
const init = (api) => {
api.intercept("add-rule", ev => {
ev.edit = false;
ev.rule.includes = ["Daisy"];
});
};

return (
`<FilterBuilder
value={value}
options={options}
fields={fields}
init={init}
/>`
);
};

export default MyComponent;

Related articles: