@joebobstevedave/ngx-cache-platform-browser v8.0.0
@ngx-cache/platform-browser

SPA/Browser platform implementation of ngx-cache
Please support this project by simply putting a Github star. Share this library with friends on Twitter and everywhere else you can.
NOTICE
This 7.x.x branch is intented to work with
Angular v7.x.x. If you're developing on a later release of Angular thanv7.x.x, then you should probably choose the appropriate version of this library by visiting the master branch.
Table of contents:
Prerequisites
This library depends on Angular v6.0.0. Older versions contain outdated dependencies, might produce errors.
Also, please ensure that you are using Typescript v2.7.2 or higher.
Getting started
Installation
You can install @ngx-cache/platform-browser using npm
npm install @ngx-cache/platform-browser --saveNote: You should have already installed [@ngx-cache/core].
Examples
- ng-seed/universal is an officially maintained seed project, showcasing common patterns and best practices for
@ngx-cache/platform-browser.
Related packages
The following packages may be used in conjunction with @ngx-cache/platform-browser:
Adding @ngx-cache/platform-browser to your project (SystemJS)
Add map for @ngx-cache/platform-browser in your systemjs.config
'@ngx-cache/platform-browser': 'node_modules/@ngx-cache/platform-browser/bundles/platform-browser.umd.min.js'app.module configuration
Angular (SPA) application
- Import
CacheModuleusing the mapping'@ngx-cache/core'and appendCacheModule.forRoot({...})within the imports property of app.module (considering the app.module is the core module in Angular application). - Import
BrowserCacheModuleusing the mapping'@ngx-cache/platform-browser'and appendBrowserCacheModule.forRoot({...})within the imports property of app.module. - Import
CACHEinjection token using the mapping'@ngx-cache/core',MemoryCacheServiceorLocalStorageCacheService(of your choice) using the mapping'@ngx-cache/platform-browser'. - Provide
CACHEusingMemoryCacheServiceorLocalStorageCacheService(of your choice), by calling the forRoot static method using theBrowserCacheModule.
app.module.ts
...
import { CacheModule, CACHE } from '@ngx-cache/core';
import { BrowserCacheModule, MemoryCacheService } from '@ngx-cache/platform-browser';
// import { BrowserCacheModule, LocalStorageCacheService } from '@ngx-cache/platform-browser';
...
@NgModule({
declarations: [
AppComponent,
...
],
...
imports: [
...
CacheModule.forRoot(),
BrowserCacheModule.forRoot([
{
provide: CACHE,
useClass: MemoryCacheService // or, LocalStorageCacheService
}
]),
],
...
bootstrap: [AppComponent]
})Angular Universal application
- Import
BrowserCacheModuleusing the mapping'@ngx-cache/platform-browser'and appendBrowserCacheModule.forRoot({...})within the imports property of app.browser.module (considering the app.browser.module is the browser module in Angular Universal application). - Import
CACHEinjection token using the mapping'@ngx-cache/core',MemoryCacheServiceorLocalStorageCacheService(of your choice) using the mapping'@ngx-cache/platform-browser'. - Provide
CACHEusingMemoryCacheServiceorLocalStorageCacheService(of your choice), by calling the forRoot static method using theBrowserCacheModule.
app.browser.module.ts
...
import { CACHE } from '@ngx-cache/core';
import { BrowserCacheModule, MemoryCacheService } from '@ngx-cache/platform-browser';
// import { BrowserCacheModule, LocalStorageCacheService } from '@ngx-cache/platform-browser';
...
@NgModule({
declarations: [
AppComponent,
...
],
...
imports: [
...
BrowserCacheModule.forRoot([
{
provide: CACHE,
useClass: MemoryCacheService // or, LocalStorageCacheService
}
]),
],
...
bootstrap: [AppComponent]
}):+1: Yeah!
@ngx-cache/platform-browserwill now provide browser platform implementation to @ngx-cache/core.
Credits
- universal-starter: Angular 2 Universal starter kit by @AngularClass
License
The MIT License (MIT)
Copyright (c) 2018 Burak Tasci
6 years ago