angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

importing DomStorageStrategy #52

Closed robert-king closed 5 years ago

robert-king commented 5 years ago

I can't seem to import DomStorageStrategy, perhaps it's not exported?


import { Cacheable } from 'ngx-cacheable';
import { DOMStorageStrategy } from '@ngx-cacheable/common/DOMStorageStrategy';

@Injectable({
  providedIn: 'root'
})
export class UserService {
  private user$: Observable<UserDetailsViewModel> = null;

  constructor(
    private userDetailService: UserDetailService,
    private showErrorService: ShowErrorService,
  ) {}

  @Cacheable({
    maxAge: 1000 * 60 * 60 * 24,
    storageStrategy: DOMStorageStrategy,
  })
  public getAvatar(): Observable<string> {
    return this.userDetailService.UserDetailGetUserAvatar();
  }

I get an error:


Failed to compile.

./src/app/some-services/user.service.ts
Module not found: Error: Can't resolve '@ngx-cacheable/common/DOMStorageStrategy' in '/Users/robertking/go/src/bitbucket.org/borndigital-nz/barker.mybarker/front-end/src/app/some-services'
angelnikolov commented 5 years ago

@robert-king The import should be import { DOMStorageStrategy } from 'ngx-cacheable/common/DOMStorageStrategy'; Let's leave this issue up until I fix that in the README :)

angelnikolov commented 5 years ago

README updated.