Custom Adapters
Introduction
Creating a custom adapter allows you to define your own logic for data serialization/deserialization, giving you more control and flexibility over how data is handled in your ReactiveModel instances.
Steps to Create a Custom Adapter
1. Implement the IResponseAdapter Interface
IResponseAdapter InterfaceFirst, create a new class that implements the IResponseAdapter interface:
class MyCustomAdapter implements IResponseAdapter {
toClient(data: any): any {
// Transform data to client format
return data;
}
fromRemote(data: any): any {
// Transform data received from remote API
return data;
}
fromRemoteList(data: any): any {
// Transform list data received from remote API
return data;
}
}2. Use the Custom Adapter
Global Scope
To set the custom adapter as the default for all instances:
Per Instance Scope
To use the custom adapter for specific Item or Collection instances:
Last updated