Storage #

Modules do not have access to conventional persistent storage methods, such as localStorage. Instead, a Storage API is exposed to Modules that allows for two different transports for storage:

  • local - Stores data on the User's local Computer
  • cloud - Stores data in the CastHub Cloud for use anywhere

NOTE: The cloud Storage transport is not currently available.

Storing Data #

this.store({
    key: 'hello-world',
    val: 'Testing 123!',
    transport: 'local', // Optional: Defaults to `local`
}).then(() => {
    console.log('Store completed!');
});

Fetching Data #

this.fetch({
    key: 'hello-world',
    def: 'Value not set', // Optional: A default value if none exists
    transport: 'local', // Optional: Defaults to `local`
}).then(val => {
    console.log('Fetch completed!', val);
});