Skip to main content

API handlers for saving and loading

Overview

You can use the API handlers instead of the predefined REST API to store:

When users click the save or load buttons in the UI, these actions initiate the saving and loading processes. API handlers allow implementing custom logic for save/load actions coming from UI. For example, you can add authorization headers or manage specific errors. Note that you need to have your own backend service to use API handlers.

How to implement

Add the save_load_adapter property to the Widget Constructor. save_load_adapter is an ​IExternalSaveLoadAdapter object that contains the save/load functions. The library calls these functions when users click save/load UI elements.

Examples

localStorage

The TypeScript example below shows how to implement in-memory saving logic, so that the data is saved within the browser's localStorage.

In-memory

The JavaScript example below shows how to implement in-memory saving logic, so that the data is saved only within the memory of the current tab. You can use this example for testing purposes or improve it by replacing the internals of these methods with calls to an external server.