rxjs5

RXJS: TypeError: this._subscribe is not a function

大憨熊 提交于 2019-12-23 07:36:01
问题 I'm migrating an ionic 3.8 app to 3.9.2. This migration includes an update to RXJS 5.5 I'm now experiencing this error: TypeError: this._subscribe is not a function. (In 'this._subscribe(sink)', 'this._subscribe' is an instance of t) After hours of debugging, I found out that this code portion is related to the error: protected observeConnectionState() { // rxjs/observable/of of(new Event('disconnect')) .pipe( // rxjs/operators/merge merge(connect$), merge(disconnect$), // Map eventname to

How to apply rxjs operator to data got from angularfire2

我怕爱的太早我们不能终老 提交于 2019-12-23 04:21:17
问题 Suppose I requested for data in angularfire2 like this: var ref = new Firebase("firebase url"); Now how can I apply rxjs operator like map operator to the data coming 回答1: I don't think you are looking at angularfire2 there - that's v1 code... You can use the rxjs operators in angularfire2 - the data is returned as an Observable (FirebaseListObservable or FirebaseObjectObservable) - so you can import and apply any of the rxjs operators to those... In general, you just assign the data to a

Property 'map' does not exist on type 'Observable' after upgrading rxjs to 6

僤鯓⒐⒋嵵緔 提交于 2019-12-23 03:39:10
问题 I upgraded my Angular application from version 5.2 to 6.0 with the instructions from https://update.angular.io. Now my Angular application doesn't build because of the "rxjs-5-to-6-migrate" migration: ERROR in bla.ts: error TS2339: Property 'map' does not exist on type 'Observable'. I have the following imports: import { Observable } from 'rxjs/observable'; import { of } from 'rxjs/observable/of'; import { map } from 'rxjs/operators'; If I change the imports like this it works: import {

Angular 2 / RXJS - need some help batching requests

百般思念 提交于 2019-12-22 12:28:48
问题 I keep reading rxjs documentation but getting lost in all the operators.. this is what i got so far let obs = Observable.from([1, 3, 5]) so what i need this to do is take() some set amount from the array. use the results in a post request, when that comes out successful then i need to restart the process. I want to collect all the results, and keep progress as the process is going (for a progress bar) I don't need the code for all of that. what i really need to know is how to use rxjs to

Conditional emission delays with rxjs

删除回忆录丶 提交于 2019-12-22 09:56:37
问题 From picture to code? How to get the Out observable from Data and Gates? Data is an observable of any kind e.g. JSON objects to be sent to a remote backend Gates is a boolean observable, where the ticks correspond to true and the crosses to false. For example, Internet connectivity whereby true means the network became accessible and false reflects a disconnection. Out is the resulting observable, which emits the same as Data, sometimes immediately, sometimes with a delay, depending on the

Should rxjs subjects be public in the class?

吃可爱长大的小学妹 提交于 2019-12-22 04:42:29
问题 Let's say I have two classes, where you can observe over some observables. First example, with public subject: class EventsPub { public readonly onEnd = new Subject<void>(); } Second example, with private subject and registering method: class EventsPriv { private readonly endEvent = new Subject<void>(); public onEnd(cb: () => void): Subscription { return this.endEvent.subscribe(cb); } } The first example is somehow unsafe because anyone can call eventsPub.endEvent.next() from outside the

Example RxJS Observable when mouse or click activity Re-starts

爷,独闯天下 提交于 2019-12-22 01:30:31
问题 I'm able to create 2 observables to watch mouse move and click events as such: var mousemove$ = Rx.Observable.fromEvent(document, 'mousemove'); var click$ = Rx.Observable.fromEvent(document, 'click'); I'm also able to use merge() and debounceTime() to wait for either mousemove or click to not happen for 10 seconds like this: var allactivity$ = Rx.Observable.merge( mousemove$.mapTo('Mouse!'), click$.mapTo('Click!') ); var lastact$ = allactivity$.debounceTime(10000); However, I would like to

Unit Test RxJS Observable.timer using typescript, karma and jasmine

好久不见. 提交于 2019-12-21 12:20:01
问题 Hi I'm relatively new to Angular2, Karma and Jasmine. Currently I'm using Angular 2 RC4 Jasmine 2.4.x I have an Angular 2 service which periodically calls an http service like this: getDataFromDb() { return Observable.timer(0, 2000).flatMap(() => { return this.http.get(this.backendUrl) .map(this.extractData) .catch(this.handleError); }); } Now I want to test the functionality. For testing purposes I have just tested the "http.get" on a separate function without the Observable.timer by doing:

Angular - what is the preferred way to terminate Observables?

谁都会走 提交于 2019-12-21 09:33:50
问题 From my understanding of Angular and RxJs there are two ways to terminate Observables. You can unsubscribe() from them or use takeUntil() and complete() . Below are examples of each approach (in pseudocode). The unsubscribe() approach private _id: number; private _subscriptions: Subscription[] = []; constructor(private _route: ActivatedRoute) { this._getId(); } public ngOnDestroy(): void { this._subscriptions.forEach( subscription => subscription.unsubscribe() ); } private _getId(): void {

Pipe RxJS observable to existing subject

荒凉一梦 提交于 2019-12-21 07:09:39
问题 There is existing subject that is in use: const fooSubject = new BehaviorSubject(null); And there is another observable (another subject in this example): const barSubject = new Subject(); barSubject.subscribe( value => fooSubject.next(), err => fooSubject.error(err), () => fooSubject.complete() ); barSubject.next('bar'); The code works but looks clumsy. Is there a better way to pipe (in broad sense, not necessarily using pipe operator) barSubject observable to fooSubject ? It looks like an