
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
angular-async-cache
Advanced tools
A simple utility to help with caching of promises and observables to enable an easy offline first approach in angular 2.0+ apps
A simple utility to help with caching of promises and observables to enable an easy offline first approach in angular 2.0+ apps
Install through npm:
npm install --save angular-async-cache
Sample usage
import { NgModule, Component, Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { AsyncCache, LocalStorageDriver, MemoryDriver, AsyncCacheModule } from 'angular-async-cache';
// declare in your module
@NgModule({
imports: [
AsyncCacheModule.forRoot({
driver: new LocalStorageDriver(), // default cache driver to use. Default in memory. You can also roll your own by implementing the CacheDriver interface
fromCacheAndReplay: true // this is the special sauce - first emit the data from localstorage, then re-fetch the live data from the API and emit a second time. The async pipe will then re-render and update the UI
})
]
})
class MyModule {}
// use in your service
@Injectable()
class CarService {
constructor(
private http: Http,
private asyncCache: AsyncCache,
private memoryDriver: MemoryDriver
) {}
getCars(): Observable<Car[]> {
const cars$: Observable<Car[]> = this.http.get('/cars').map(res => res.json());
return asyncCache.wrap(cars$, '/cars', {
driver: this.memoryDriver, // override the default and cache the data in memory
});
}
}
// finally use with the async pipe in your components template
@Component({
template: `
<div *ngFor="let car of cars | async">
{{ car.model }}
</div>
`
})
class MyComponent {
cars: Observable<Car[]>;
constructor(carService: CarService) {
this.cars = carService.getCars();
}
}
// alternatively use the asyncCache pipe in your template, this way you also dont need to wrap the observable beforehand
@Component({
template: `
<div *ngFor="let car of cars | asyncCache:'/cars' | async">
{{ car.model }}
</div>
`
})
class MyComponent {
cars: Observable<Car[]>;
constructor(http: Http) {
this.cars = http.get('/cars').map(res => res.json());
}
}
npm install while current directory is this repoRun npm start to start a development server on port 8000 with auto reload + tests.
Run npm test to run tests once or npm run test:watch to continually run tests.
npm run release
MIT
FAQs
A simple utility to help with caching of promises and observables to enable an easy offline first approach in angular 6+ apps
The npm package angular-async-cache receives a total of 22 weekly downloads. As such, angular-async-cache popularity was classified as not popular.
We found that angular-async-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.