Local storage service - luftsport/nlf-client GitHub Wiki

LocalStorage

import { LocalStorage } from '@ngx-pwa/local-storage';

constructor(private storage: LocalStorage) {}

// Setter
this.storage.setItem('auth-id', data.username).subscribe(() => { });

// Getter
this.storage.getItem<String>('auth-id').subscribe(id => {
      if (!!id) {
          ...
      }

// Clear
this.storage.clear().subscribe(() => {}));

Example

this.storage.getItem('auth-id').subscribe(person_id => {
      this.membership.getUser(this.id).subscribe(
          data => {...}
      );
});

Async

this.activity = this.storage.getItem<number>('default-activity');
and
{{ activity | async }}

Deprecated

import { NlfLocalStorageService } from 'app/services/storage/local-storage.service';
...
constructor(private storage: NlfLocalStorageService) {}

Then use it as

  • getId()
  • getSettings()
  • getSetting('default_club')
⚠️ **GitHub.com Fallback** ⚠️