A data module is a JavaScript object used to extend RemoteStorage with custom logic and data management. It must contain two properties:
name: A string representing the module's identifier.builder: A function that is called when the module is loaded.
The builder function receives two BaseClient instances as arguments:
privateClient: For managing data stored in /[module-name]/.publicClient: For managing data stored in /public/[module-name]/.
The builder must return an object containing an exports property. The exports object defines the API (functions and properties) that will be exposed on the RemoteStorage instance.
Example structure:
const MyModule = {
name: 'my-module',
builder: function(privateClient, publicClient) {
return {
exports: {
myFunction: function() {
// Use privateClient or publicClient here
}
}
};
}
};
const Bookmarks = {
name: 'bookmarks',
builder: function(privateClient, publicClient) {
return {
exports: {
addBookmark: function() {}
}
}
}
};