Token used to inject an object as the storage backend of the SessionStorage object. By default, the storage backend is the native localStorage object but can be substituted to allow for testing or customized storage like to remote storage.
An object that SERializes and DESeriallizes values for storage. The default implementation for the SerDes object is:
{ provide: SERDES_OBJECT, useValue: { stringify: JSON.stringify, parse: JSON.parse } }
which is essentially the
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON" class="external">window.JSON</a>
object.
Due to the fact that the JSON object is also an interface in TypeScript, it couldn't be used as-is. This is the reason
the default implementation defines the stringify
and parse
methods individually instead of just using the JSON object
as the value.
Should you want to implement customized serialization and deserialization for something like encrypted storage, simply provide new methods for stringify and parse and you're good to go.
Token used to inject an object as the storage backend of the SessionStorage object. By default, the storage backend is the native sessionStorage object but can be substituted to allow for testing or customized storage like to remote storage.
The token used to allow injection of the StorageOptions interface. For more information visit the angular2 docs.
Creates a provider for the StorageOptions
A StorageOptions object
A decorator that associates a property with a key in storage
An object containing properties to determine how the property behaves
export class TodoApp {
//setup a default value. If a value is already defined, it will not be overwritten
@StorageProperty()
public settings: any = { list: "todolist", hideDoneItems: true };
constructor(private localStorage: LocalStorage) {...}
}
export class TodoApp {
//setup a default value. If a value is already defined, it will not be overwritten
@StorageProperty({storage: "Session"})
public settings: any = { list: "todolist", hideDoneItems: true };
constructor(private sessionStorage: sessionStorage) {...}
}
export class TodoApp {
//setup a default value. If a value is already defined, it will not be overwritten
@StorageProperty({readOnly: true, storageKey: "mysettings"})
public settings: any = { list: "todolist", hideDoneItems: true };
constructor(private localStorage: LocalStorage) {...}
}
Associates a property with a key in storage
Generated using TypeDoc
The objects necessary to use Web Storage in the browser