Settings
Setting General Configurations
The ReactiveConfig class in ReactiveModel allows you to set global configurations that will be applicable for all
instances of ReactiveModel. This can be particularly useful for setting up a default or custom adapter for handling data
serialization/deserialization.
Importing the Settings Module
To access the ReactiveConfig class, you should import it from the package as follows:
import { ReactiveConfig } from '@beyond-js/reactive/settings';Interfaces
IResponseAdapter
IResponseAdapterThis interface outlines the required methods for a custom adapter.
interface IResponseAdapter {
toClient: (data: any) => any;
fromRemote: (data: any) => any;
fromRemoteList?: (data: any) => any;
}toClient: Transforms data to be sent to the client.fromRemote: Transforms single-item data received from remote API.fromRemoteList: Transforms list data received from remote API.
IConfig
IConfigThis interface outlines the structure of the configuration object.
adapter: Specifies which adapter to use ('legacy', 'default', or a custom adapter class).
Class Structure
Usage
To set the configuration, you can use the set method of ReactiveConfig. The set method takes an object conforming
to the IConfig interface.
or with a custom adapter:
This will apply the configurations globally across all instances of ReactiveModel.
Conclusion
Using the ReactiveConfig class to set global configurations provides a centralized way to manage important aspects of
your ReactiveModel instances.
Last updated