Skip to main content

View Service

The View Service provides storage and persistence capabilities for view schemas, allowing you to save, retrieve, and manage view definitions.

Overview

The View Service offers the following functionality:
  • Initialization with different storage providers
  • Saving and retrieving view schemas
  • Listing available view schemas
  • Deleting view schemas
  • Support for both client and server-side storage

API Reference

initViewService

Initializes the view service with the specified storage options.

saveView

Saves a view schema to the storage provider.

getView

Retrieves a view schema from the storage provider.

listViews

Lists all available view schemas from the storage provider.

deleteView

Deletes a view schema from the storage provider.

exportViews

Exports all view schemas as a JSON string.

importViews

Imports view schemas from a JSON string.

Storage Providers

The View Service supports the following storage providers:

Local Storage Provider

Stores view schemas in the browser’s localStorage.

Session Storage Provider

Stores view schemas in the browser’s sessionStorage.

Server Storage Provider

Stores view schemas on a server using REST API calls.

Custom Storage Provider

Allows you to implement your own storage provider.

Examples

Initializing the View Service

Saving and Retrieving Views

Listing and Deleting Views

Exporting and Importing Views

Integration with React

The View Service can be integrated with React using hooks:

Server-Side Implementation

For server-side storage, you need to implement the following REST API endpoints:
  • GET /api/views: List all views
  • GET /api/views/:id: Get a specific view
  • POST /api/views/:id: Save a view
  • DELETE /api/views/:id: Delete a view
Here’s an example using Next.js API routes: