Class ClientStorage

Creates a new client storage for the current context.

It provides methods to work with the client data. The storage methods can be used directly from the the controller’s context through the storage key.

Examples

this.context.storage.set('cart', { items: [1, 2, 3, 4], total: 10});
var data = this.context.storage.get('cart');
console.log(data);

// That will print
//     {
//         items: [1, 2, 3, 4],
//         total: 10
//     }

Constructor

class ClientStorage(context)
Arguments:
  • context (Context) – the context of the component.

Methods

get

ClientStorage#get(key[, isTransient])
Arguments:
  • key (String) – the key
  • isTransient (Boolean) – whether to use persistent storage or transient storage (Default: ‘false’)
Returns Object:

the key value

Retrieves the value of a key from storage.

remove

ClientStorage#remove(key[, isTransient])
Arguments:
  • key (String) – the key
  • isTransient (Boolean) – whether to use persistent storage or transient storage (Default: ‘false’)

Removes a key from storage.

set

ClientStorage#set(key, value[, isTransient])
Arguments:
  • key (String) – the key
  • value (Object) – the value
  • isTransient (Boolean) – whether to use persistent storage or transient storage (Default: ‘false’)

Sets the value of a key (add it if key doesn’t exist) into storage.

Table Of Contents

Previous topic

Class ClientRenderer

Next topic

Class Context