Data Management
The FDK Store is a package that serves as a wrapper over the FDK Client Javascript SDK, providing users with a convenient interface to interact with the SDK's functionality. This package utilizes Redux Toolkit to manage the application state and automatically updates the store based on actions performed through the SDK. The FDK Store exports a class that encapsulates the Redux store and exposes methods for interacting with the SDK and retrieving data from the store. It also includes a getters object that provides getter functions for different slices of the store
fdk-store:- https://github.com/gofynd/fdk-store/blob/v2.0.2/docs/API.md
fdk-store-gql:- https://github.com/gofynd/fdk-store-gql/blob/v1_0_1/README.md
Installation
To install the FDK Store package in your project, run the following command:
npm install `https://github.com/gofynd/fdk-store.git#v2.0.2
Usage
Importing the Package
To import the FDK Store package into your project, use the following import statement:
import FDKStore from 'fdk-store';
Creating an Instance
Create an instance of the FDKStore
const fpiOptions = {
applicationID,
applicationToken,
domain,
storeInitialData,
};
const { client: fpi } = new FDKStore(fpiOptions);
📄️ Retrieve FPI using useFPI Hook
Theme developers can use the useFPI hook to effortlessly retrieve FPI in any nested component, streamlining API calls
📄️ Using FPI Client Instance
The FPI client is available on every page by useFPI hook. Theme developers can use this client to fetch and sync data with their Redux stores.
📄️ Set Custom Value to Store
Theme developers can set a custom value in redux store using fpi.custom.setValue('keyname', value) and retrieve the value using the getter fpi.getters.CUSTOM_VALUE.
📄️ Observe Store
The observeStore function allows developers to subscribe to a specific part of the Redux store and receive updates when that part changes. It functions similarly to the useGlobalStore hook, but is designed to be used in vanilla JavaScript, making it more flexible for different environments.