Skip to content

Not possible to use catch / filter / or any other RxJs Observable methods after setItem(...) #10

Closed
@atiris

Description

@atiris

Hi. How can I catch errors and transform it into Observable.of(false)?
Or how to use filter or any other Observable method from setItem('local-storage-variable', variable) observable? I want to use catch, but I try filter also and always with the same result:

Part of my code:

...
import { AsyncLocalStorage } from 'angular-async-local-storage';
import { Observable } from 'rxjs/Observable'; // I try it also from rxjs/Rx
import 'rxjs/add/operator/catch'; // I try it also without this line
...
@Injectable()
export class SessionService {
  constructor(
    private asyncLocalStorage: AsyncLocalStorage,
    ...
  ) { }
  public logout(): Observable<boolean> {
    return this.asyncLocalStorage.setItem('session', this.session)
      .filter(f => f === true) // error on this line
      .catch(err => Observable.of(false)); // error on this line if previous is commented
  }

Errors:
ERROR TypeError: this.asyncLocalStorage.setItem(...).filter is not a function
ERROR TypeError: this.asyncLocalStorage.setItem(...).catch is not a function
Versions in angular project: "angular-async-local-storage": "^2.0.0", "rxjs": "^5.4.3"

Thank you in advance very much for your help.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions