Returns the value associated with the given key, or undefined if
no such value exists.
Returns a storage namespace operating on the given key that can be used to group
multiple related properties.
key should either be associated with an object or it's value should be undefined.
If key is not associated with a value, a new empty object will be created.
Namespaces allow you to treat an object in local storage as a group of properties. Getting (or setting) a key using a Namespace object will simply read (or update) properties on the managed object instead.
If key has already been set to something that is not an object, you will receive an error
if you attempt to call this method.
Example:
const storageService = ...; // injected
// Namespace operates on the "my-package-name" object (which may not exist yet)
const packageNamespace = storageService.getNamespace("my-package-name");
// Setting the first value will ensure that the object exists
packageNamespace.set("foo", "bar"); // actually sets `"my-package-name" -> "foo"`
// Retrieving the same object ("my-package-name") via get():
const backingObject = storageService.get("my-package-name"); // {"foo": "bar"}
console.log(backingObject);
Removes any value associated with key.
Removes all entries associated managed by this instance.
If this represents the root object, all entries will be removed.
If this represents a (possibly nested) namespace, only the contents of that
namespace will be removed.
Associates the given value with key.
This method supports arbitrary JSON compatible values, including objects and arrays. If you store an object, you can later access (or modify) its individual properties using getNamespace.
NOTE: This function creates a clone of the original value to protect against accidental side effects. Updating the original value after
set()will have no effect on the stored value.
Provides basic operations to interact with the browser's local storage.
The operations provided by this interface always act on an object in local storage: either the root value or a nested object.