RemoteStorage.defineModule

RemoteStorage.defineModule = function(moduleName,
builder)

Method for defining a new remoteStorage data module

Parameters

moduleNameName of the module
builderBuilder function defining the module

The module builder function should return an object containing another object called exports, which will be exported to any RemoteStorage instance under the module’s name.  So when defining a locations module, like in the example below, it would be accessible via `remoteStorage.locations`, which would in turn have a `features` and a `collections` property.

The function receives a private and a public client, which are both instances of RemoteStorage.BaseClient.  In the following example, the scope of privateClient is `/locations` and the scope of publicClient is `/public/locations`.

Example

RemoteStorage.defineModule('locations', function(privateClient, publicClient) {
  return {
    exports: {
      features: privateClient.scope('features/').defaultType('feature'),
      collections: privateClient.scope('collections/').defaultType('feature-collection')
    }
  };
});
TODO needs proper introduction and links to relevant classes etc
Close