11.0.0 • Published 4 months ago
ngforage v11.0.0
ngforage
localforage bindings for Angular
You can also npm install manually:
npm install localforage@^1.10.0 ngforage@^11.0.0 # Angular 17
npm install localforage@^1.10.0 ngforage@^10.0.0 # Angular 16
npm install localforage@^1.10.0 ngforage@^9.0.0 # Angular 15
npm install localforage@^1.10.0 ngforage@^8.0.0 # Angular 14
npm install localforage@^1.9.0 ngforage@^7.0.0 # Angular 13
npm install localforage@^1.5.0 ngforage@^6.0.0 # Angular 9
npm install localforage@^1.5.0 ngforage@^5.0.0 # Angular 8
npm install localforage@^1.5.0 ngforage@^4.0.0 # Angular 7
npm install localforage@^1.5.0 ngforage@^3.0.0 # Angular 6
npm install localforage@^1.5.0 ngforage@^2.0.0 # Angular 5
@Component({
/* If you plan on making per-component config adjustments, add the services to the component's providers
* to receive fresh instances; otherwise, skip the providers section.
*/
providers: [NgForage, NgForageCache]
})
class SomeComponent implements OnInit {
constructor(private readonly ngf: NgForage, private readonly cache: NgForageCache) {}
public getItem<T = any>(key: string): Promise<T> {
return this.ngf.getItem<T>(key);
}
public getCachedItem<T = any>(key: string): Promise<T | null> {
return this.cache.getCached<T>(key)
.then((r: CachedItem<T>) => {
if (!r.hasData || r.expired) {
return null;
}
return r.data;
})
}
public ngOnInit() {
this.ngf.name = 'SomeStore';
this.cache.driver = Driver.LOCAL_STORAGE;
}
}
</details>
<details>
<summary>Store instances</summary>
It is recommended to declare `NgForage` and/or `NgForageCache` in providers
if you're not using the default configuration. The running configuration
hash is used to create and reuse drivers (e.g. different IndexedDB
databases), therefore setting it on a shared instance might have
unintended side-effects.
</details>
<details>
<summary>Defining a Driver</summary>
1. Define a driver as described in the [localForage docs](https://localforage.github.io/localForage/#driver-api-definedriver)
2. Plug it in, either directly through localForage or through `NgForageConfig`:
```typescript
import {NgModule} from "@angular/core";
import {NgForageConfig} from 'ngforage';
import localForage from 'localforage';
// Your driver definition
const myDriver: LocalForageDriver = {/*...*/};
// Define it through localForage
localForage.defineDriver(myDriver)
.then(() => console.log('Defined!'))
.catch(console.error);
@NgModule({})
export class AppModule {
constructor(conf: NgForageConfig) {
// Or through NgForageConfig
conf.defineDriver(myDriver)
.then(() => console.log('Defined!'))
.catch(console.error);
}
}
10.1.0
4 months ago
11.0.0
4 months ago
10.0.0
9 months ago
9.0.0
1 year ago
8.0.1
1 year ago
8.0.0
1 year ago
7.0.0
2 years ago
6.0.0
4 years ago
5.0.1
5 years ago
5.0.0
5 years ago
4.0.3
5 years ago
4.0.2
5 years ago
4.0.1
6 years ago
4.0.0
6 years ago
3.4.0
6 years ago
3.3.0
6 years ago
2.2.1
6 years ago
2.2.0
6 years ago
3.2.0
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
3.1.0
6 years ago
3.0.5
6 years ago
2.0.4
6 years ago
3.0.4
6 years ago
2.0.3
6 years ago
3.0.3
6 years ago
2.0.2
6 years ago
3.0.2
6 years ago
3.0.1
6 years ago
2.0.1
6 years ago
3.0.0
6 years ago
2.0.0
6 years ago
2.0.0-beta.0
6 years ago
1.0.0-rc.0
6 years ago