Manual Reference Source Test
import StorageUtility from 'clinical6/src/utilities/StorageUtility.js'
public class | source

StorageUtility

Storage will store and retrieve data. This is expected to have set and get methods overwritten if necessary.

Example:

import { Storage } from 'clinical6';
Storage.set('kittens', 5);
Storage.get('kittens');

Static Member Summary

Static Public Members
public static
public static get

Get the instance of the storage utility

Constructor Summary

Public Constructor
public

constructor(enforcer: Symbol)

Constructor

Member Summary

Public Members
public

Method Summary

Public Methods
public

clear(type: String, id: String): Promise<any>

Clear storage data.

public

get(type: String, options: Object): Promise<any>

Get storage data.

public

has(type: String, id: Number): Boolean

Determines if the type and id exist in storage

public

set(type: String, value: String, options: Object): Promise<any>

Set storage data.

Static Public Members

public static [storageSingleton]: Client source

public static get instance: Object source

Get the instance of the storage utility

Public Constructors

public constructor(enforcer: Symbol) source

Constructor

Params:

NameTypeAttributeDescription
enforcer Symbol

Public Members

public data: Object source

Public Methods

public clear(type: String, id: String): Promise<any> source

Clear storage data.

Params:

NameTypeAttributeDescription
type String
  • optional

Type/Key of item to clear

id String
  • optional

The id, if you want to store a specific item

Return:

Promise<any>

Promise to indicate the clear is finished

Throw:

Clinical6Error

If type is not a string

Example:

import { Storage } from 'clinical6';
Storage.clear('kittens');
Storage.clear();

public get(type: String, options: Object): Promise<any> source

Get storage data.

Params:

NameTypeAttributeDescription
type String
  • nullable: false

Type/Key of item to get - should be server's obj type

options Object
  • optional
  • nullable: true

Options for getting storage information

options.id String
  • optional

The id, if you want to store a specific item

options.asArray String
  • optional

Return as array

Return:

Promise<any>

Promise with the stored data

Throw:

Clinical6Error

If type is empty or not a string

Example:

import { Storage } from 'clinical6';
Storage.get('kittens');

public has(type: String, id: Number): Boolean source

Determines if the type and id exist in storage

Params:

NameTypeAttributeDescription
type String

The key of the storage location

id Number
  • optional

The id belonging to the item in question

Return:

Boolean

Whether or not the item exists

public set(type: String, value: String, options: Object): Promise<any> source

Set storage data.

Params:

NameTypeAttributeDescription
type String
  • nullable: false

Type/Key of item to store - should be server's obj type

value String

Value of item to store

options Object
  • optional
  • nullable: true

Options for setting storage information

options.id String
  • optional

The id, if you want to store a specific item

options.key String
  • optional

The key, if you want to store a specific key. Only used if value is an array

Return:

Promise<any>

Promise with the stored data

Throw:

Clinical6Error

If key/value is empty or not a string

Example:

import { Storage } from 'clinical6';
Storage.set('kittens', 5);