LoginComponent.html:18 ERROR TypeError: Observable.Observable.of is not a function
at LogConsole.webpackJsonp../node_modules/angular-logger/angular-logger.umd.js.LogConsole.log (angular-logger.umd.js:142)
at LogService.webpackJsonp../node_modules/angular-logger/angular-logger.umd.js.LogService.writeToLog (angular-logger.umd.js:351)
at LogService.webpackJsonp../node_modules/angular-logger/angular-logger.umd.js.LogService.fatal (angular-logger.umd.js:311)
at LoginComponent.webpackJsonp../src/app/user/login/login.component.ts.LoginComponent.hi (login.component.ts:83)
at Object.eval [as handleEvent] (LoginComponent.html:18)
at handleEvent (core.js:13254)
at callWithDebugContext (core.js:14739)
at Object.debugHandleEvent [as handleEvent] (core.js:14326)
at dispatchEvent (core.js:9703)
at core.js:10317
I'm getting this error in the app consuming my custom logger library.
login.component.ts:
hi(){
alert('hi!');
this.logService.fatal('hi there!');
}
which ends up calling the following function in my custom logger library, which is the cause of the error:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import { LogPublisher } from './log-publisher.class';
import { LogEntry } from './log-entry.class';
export class LogConsole extends LogPublisher {
log(record: LogEntry) : Observable<boolean> {
console.log(record.buildLogString());
return Observable.of(true);
}
}
I tried changing the import url for the 'of' operator, with no success.
The rxjs version in the custom logger library is
"dependencies": {
"rxjs": "~5.5.0"
}
and the version in the consuming app is:
"rxjs": "~5.5.0"
You should use the newer version of invoking Rxjs methods:
import {of} from 'rxjs/observable/of';
and then :
return of(true);
Update rxjs version 6:
import { of } from 'rxjs';