rxjs

rxjs/Subscription has no exported member 'Subscription'

对着背影说爱祢 提交于 2019-12-18 01:53:25
问题 I updated my angular project and all my dependencies to latest version. Without to much trouble I solved most of the dependency issues, but I'm still stuck on RxJS. Here is my package.json: "dependencies": { "@angular-devkit/build-angular": "^0.6.0", "@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

rxjs flatmap missing

风格不统一 提交于 2019-12-18 01:18:51
问题 I try to chain multiple rx.js observables and pass the data. Flatmap should be the fitting operator but with an import of import { Observable } from 'rxjs/Observable'; it is not found: Error TS2339: Property 'flatmap' does not exist on type 'Observable<Coordinates>' Version 5.0.0-beta.6 of rx.js is used. public getCurrentLocationAddress():Observable<String> { return Observable.fromPromise(Geolocation.getCurrentPosition()) .map(location => location.coords) .flatmap(coordinates => { console.log

Reconnecting a websocket in Angular and rxjs?

痞子三分冷 提交于 2019-12-17 23:43:04
问题 I have a ngrx/store (v2.2.2) and rxjs (v5.1.0) based application that listens to a web socket for incoming data using an observable. When I start the application I receive incoming data flawlessly. However after a while (updates are coming in quite infrequently) the connection seem to get lost and I don't get anymore incoming data. My code: The service import { Injectable, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; @Injectable() export class MemberService implements

Reconnecting a websocket in Angular and rxjs?

☆樱花仙子☆ 提交于 2019-12-17 23:39:34
问题 I have a ngrx/store (v2.2.2) and rxjs (v5.1.0) based application that listens to a web socket for incoming data using an observable. When I start the application I receive incoming data flawlessly. However after a while (updates are coming in quite infrequently) the connection seem to get lost and I don't get anymore incoming data. My code: The service import { Injectable, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; @Injectable() export class MemberService implements

fromPromise does not exist on type Observable

一曲冷凌霜 提交于 2019-12-17 23:06:34
问题 In Angular 2 using rxjs I was trying to convert a Promise to Observable. As many of online guides showed I used fromPromise on Observable . Which throws error: Property 'fromPromise' does not exist on type 'typeof Observable'. Observable was imported like: import { Observable } from "rxjs/Observable"; trying to import fromPromise like other operators results in error: import 'rxjs/add/operator/fromPromise'; even if I suppress typescript error it still results in error: (<any>Observable)

Angular 6 - run method is service every 10 seconds

跟風遠走 提交于 2019-12-17 22:56:05
问题 I have this service using HttpClient to get some data : checkData() { return this.http.get('my url'); } The on the footer component I call it and display the result : ngOnInit() { this.myservice.checkdata().subscribe( result => { this.statustext = result } ); } This works, but I need this method to be run every 10 seconds so it's up to date. How can I do this? 回答1: Use rxjs timer to call the api request at startup and then every 10s. This is best achieved by using rxjs to divide and conquer.

Subscribe to both route params and queryParams in Angular 2

那年仲夏 提交于 2019-12-17 22:45:11
问题 I have set up the following routing system export const MyRoutes: Routes = [ {path: '', redirectTo: 'new', pathMatch: 'full'}, {path: ':type', component: MyComponent} ]; and have the following navigation system goToPage('new'); goToPageNo('new', 2); goToPage(type) { this.router.navigate([type]); } goToPageNo(type, pageNo) { this.router.navigate([type], {queryParams: {page: pageNo}}); } Sample URL looks like this http://localhost:3000/new http://localhost:3000/new?page=2 http://localhost:3000

Getting an object array from an Angular service

 ̄綄美尐妖づ 提交于 2019-12-17 22:33:56
问题 I am new to Angular (and Javascript for that matter). I've written an Angular service which returns an array of users. The data is retrieved from an HTTP call which returns the data in JSON format. When logging the JSON data returned from the HTTP call, I can see that this call is successful and the correct data is returned. I have a component which calls the service to get the users and an HTML page which displays the users. I cannot get the data from the service to the component. I suspect

what is a `Scheduler` in RxJS

若如初见. 提交于 2019-12-17 21:41:08
问题 I'v seen the term Scheduler very frequently in the documentation. But, what does this term mean? I even don't know how to use a so called Scheduler . The official documentation didn't tell me what a Scheduler exactly is. Is this just a common concept or a specific concept in RxJS? 回答1: Rx schedulers provide an abstraction that allows work to be scheduled to run, possibly in the future, without the calling code needing to be aware of the mechanism used to schedule the work. Whenever an Rx

Angular CanDeactivate Router Guard with an Observable Subscribed Value

社会主义新天地 提交于 2019-12-17 21:32:05
问题 I've been trying to write a canDeactivate guard to check a saving state from an observable stream and work accordingly. My service goes as this import { Injectable } from '@angular/core'; import { ReplaySubject } from 'rxjs/ReplaySubject'; import { Observable } from 'rxjs/Observable'; @Injectable() export class EditModelService { private savingModelDataSource = new ReplaySubject<boolean>(); savingModelData$ = this.savingModelDataSource.asObservable(); public setSavingModelData(state: boolean)