Just moved from rxjs 5/angular 5 to rxjs 6/ angular 6, went through this migration-guide. Can't seem to figure out what it should be now, any help appreciated.
import { Observable, of } from 'rxjs'; [ts] 'of' is declared but its value is never read. // trivial example of what im trying to replace isLoggedIn(): Observable<boolean> { return Observable.of(true); }
The "Property does not exist on type Object" error occurs when we try to access a property that is not contained in the object's type. To solve the error, type the object properties explicitly or use a type with variable key names.
RxJS' of() is a creational operator that allows you to create an RxJS Observable from a sequence of values. According to the official docs: of() converts the arguments to an observable sequence. For example: import { of } from 'rxjs'; of(1, 2, 3, 4) .
You can now just import of
from rxjs
. So....
import { Observable, of } from 'rxjs'; // trivial example of what im trying to replace isLoggedIn(): Observable<boolean> { return of(true); }
If you are using Angular 6 /7 or 9
import { of } from 'rxjs';
And then instead of calling
Observable.of(res);
just use
of(res);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With