@ngneat/storage
v1.0.0
Published
<p align="center"> <img width="20%" height="20%" src="./logo.svg"> </p>
Downloads
7
Maintainers
Readme
The simple storage implementation with support for Observable and Promise
The 'storage' library is dedicated to support various implementation of storage which implements API similar to the 'localStorage.'. The biggest advantage is support for Observable and Promise. It's allow us to add support of the custom persistence manager within following libs: @ngneat/reactive-forms, @ngneat/forms-manager, @ngneat/cashew
Table of Contents
Installation
ng add @ngneat/storage
NPM
npm install @ngneat/storage --save-dev
Yarn
yarn add @ngneat/storage --dev
Usage
By default the library provides LocalStorageManager and SessionStorageManager. It's possible to store the form value into a custom storage. Just implement the PersistManager interface, and use it when calling the upsert function. Storage supports Promise and Observable
export class StateStoreManager<T> implements PersistManager<T> {
setValue(key: string, data: T) {
...
}
getValue(key: string) {
...
}
}
Library also export's helper methods and types:
###Types
MaybeAsync
- Type that indicates that value might be Observable or Promise
###Class
StorageFacade
- Accepts PersistManager implementation as parameter and implements get and update methods.get
Return value for the given keyupdate
- Update storage under specific key using provided callback function.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!