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​

import { getData, getDrive } from "./common/data";
import { Filemanager } from "@svar-ui/react-filemanager";

function App() {
function init(api) {
api.on("show-preview", ({ mode }) => {
console.log(`Preview is ${mode ? "visible" : "hidden"}`);
});
}

return <Filemanager data={getData()} drive={getDrive()} init={init} />;
}

export default App;

Related articles: