I updated rxjs to 6.1.0. And I want to refactor my imports to new style. I mean:
import { Observable, of } from 'rxjs';
But this is gave me an error:
// return Observable.of(data);
error TS2339: Property 'of' does not exist on type 'typeof Observable'.
map import wokrs (I think)
import { map } from 'rxjs/operators';
return this.http.post(url, data).pipe(
map(res => res)
)
What should I do?
i also append my dependencies
"@agm/core": "1.0.0-beta.2",
"@angular/animations": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"brace": "0.11.0",
"codemirror": "5.33.0",
"core-js": "^2.5.4",
"dragula": "3.7.2",
"moment": "2.20.1",
"ngx-quill": "2.0.4",
"rxjs": "^6.1.0",
"rxjs-compat": "^6.1.0",
"spinkit": "1.2.5",
"ts-helpers": "1.1.2",
"zone.js": "^0.8.26"
and my devDependencies
"@angular-devkit/build-angular": "~0.6.0",
"@angular/cli": "~6.0.0",
"@angular/compiler-cli": "^6.0.0",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "^2.7.2"
Previously
import 'rxjs/add/observable/of';
// or
import { of } from 'rxjs/observable/of
const source = Observable.of(1, 2, 3, 4, 5);
const subscribe = source.subscribe(val => console.log(val));
In RXJS:6 syntax has changed and import too Instead of Observable.of
use of
import { Observable, of } from 'rxjs';
const source = of(1, 2, 3, 4, 5);
const subscribe = source.subscribe(val => console.log(val));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments