
So two different libraries that might use the persistence library, have less chance of attributes conflicting. Secondly, it provides an isolated grouping of objects that are stored in a namespace. This allows you to create a container that will store a value in a certain way, and all getters and setters will use the same configuration when loading and saving attributes. First off, they provide a much simpler interface then calling the service methods directly, especially when configuration options or non-MEMORY storage types are used because the configuration is specified when the container is created.
Isolated Persistence Containers serve two needs throughout the system. set ( ' myName ', ' scott ', ) 4 Isolated Containers This option is great for short term storage. Some methods (like createCache) can't support the oneUse option because of thier nature.
oneUse - this option is not available for all configurable methods. Unlike the timeout, this value will not reset when the value is read, only when a new value is set. expireAfter - specifies after how much time (in ms) the stored value will be valid for after it has been set.
Every time the value is accessed via the 'get' or 'cache' method, the timeout counter is restarted.
timeout - specifies a value (in ms) for when the value in the property becomes 'stale'. In the previous section we introduced you to the 'type' property of the config. In addition to storage type, the config options let the framework know when to expire items from the cache. Depending on the option, some or all of the following configuration types are available. SESSION ) 3 Storage ConfigurationĬonfig objects are used for several methods within the persistence framework to provide additional configuration. Otherwise this works just like Session storage with the same limintations. It is suggested hat you specify a "maxAge" for objects on the local storage. If used too extensively, this can clog up your browser. LOCAL: this storage type is persistent permanently. Also, unlike session storage provided by javascript, this SessionStorage CAN distinguish between a null value and undefined. This storage type is incapable of serializing objects that are not serializable via Javascripts JSON class. Even if the page is refreshed or the service instance is restarted, this storage type will persist for the current tab. Different tabs will have different values. SESSION: this storage type is persistent so long as the current browser tab is being displayed. Just like local and session storage, however, this storage type is incapable of serializing objects that are not serializable with the Javascript JSON class. This is the same as browser and local storage, only the data is not persisted beyond the service instance. IMMUTABLE_MEMORY: this storage type is just like the memory storage type EXCEPT that the objects are serialized before they are saved and then deserialized on a get. As such, this works best with immutable objects and can accomodate large data sets as well as objects that have some actual logic. This storage type WILL NOT persist among page re-loads and objects inside of this collection, if mutated, will mutate all instances of the object. This will simply store the object within the service instance's memory. MEMORY: the fastest and most flexible memory type. If not storage type is specified, MEMORY storage type is used. The StorageType enumeration contains the list of available storage types. For other methods like set and createCache, the type is specified on the config object. These are specified on get, remove, removeall, and clean methods via the type parameter.
This library is capable of handling various storage types within the browser. For complete usage, please see the API documentation. There are more options for each of these methods.
Baka loader install#
To use this library, install it via npm into your project. In addition, the library will help with cleanup of persistent cached data by keeping track of which data has been loaded and where it is put. The implementations of the various storage techniques have been expanded and normalized such that no specific knowledge should be needed of the various storage types and thier uses. This project allows you to persist data within an Angular 8 (for 7.x.x version visit for 6.x.x version visit, for 5.2.x version visit and for other olders versions, visit ) application written in TypeScript, ES6 or ES5. Library to aid in a consistent implementation of browser storage including memory, session, and local storage.