Detalhes do pacote

ngz-cache-platform-browser

fulls1z39MIT11.2.3

Browser platform implementation of ngx-cache

client side, platform-browser, caching, cache

readme (leia-me)

@ngx-cache/platform-browser npm version npm downloads

SPA/Browser platform implementation of ngx-cache

CircleCI coverage tested with jest Conventional Commits Angular Style Guide

Please support this project by simply putting a Github star. Share this library with friends on Twitter and everywhere else you can.

Table of contents:

Getting started

Installation

You can install @ngx-cache/platform-browser using npm

npm install @ngx-cache/platform-browser --save

Note: 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 CacheModule using the mapping '@ngx-cache/core' and append CacheModule.forRoot({...}) within the imports property of app.module (considering the app.module is the core module in Angular application).
  • Import BrowserCacheModule using the mapping '@ngx-cache/platform-browser' and append BrowserCacheModule.forRoot({...}) within the imports property of app.module.
  • Import CACHE injection token using the mapping '@ngx-cache/core', MemoryCacheService or LocalStorageCacheService (of your choice) using the mapping '@ngx-cache/platform-browser'.
  • Provide CACHE using MemoryCacheService or LocalStorageCacheService (of your choice), by calling the forRoot static method using the BrowserCacheModule.

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 BrowserCacheModule using the mapping '@ngx-cache/platform-browser' and append BrowserCacheModule.forRoot({...}) within the imports property of app.browser.module (considering the app.browser.module is the browser module in Angular Universal application).
  • Import CACHE injection token using the mapping '@ngx-cache/core', MemoryCacheService or LocalStorageCacheService (of your choice) using the mapping '@ngx-cache/platform-browser'.
  • Provide CACHE using MemoryCacheService or LocalStorageCacheService (of your choice), by calling the forRoot static method using the BrowserCacheModule.

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-browser will now provide browser platform implementation to @ngx-cache/core.

Credits

License

The MIT License (MIT)

Copyright (c) 2019 Burak Tasci

changelog (log de mudanças)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

9.0.0 (2020-04-27)

Features

BREAKING CHANGES

  • package: ng9
  • package: ng9

8.1.0 (2020-04-27)

Features

8.0.3 (2020-03-10)

Bug Fixes

  • core: fix value.lifeSpan is undefined (#129) (c7fb378)

8.0.2 (2020-03-10)

Bug Fixes

8.0.1 (2019-11-21)

Note: Version bump only for package ngx-cache

8.0.0 (2019-11-21)

Bug Fixes

Features

  • package: upgrade to angular 8 (dfb4d73)

BREAKING CHANGES

  • package: ng8