observable

Chain and merge 3 RxJS Observables with result dependences without nesting in TypeScript and Angular 4

风流意气都作罢 提交于 2021-02-07 14:39:13
问题 I have 3 observables that i need to chain, result from first one is used in the other 2. They must run in order and each one must wait for the previous one to finish. Is it possible to chain then without nesting? public observable1(): Observable<Response> { let headers = new Headers(); headers.append("Content-Range", "bytes */*"); let requestOptions = new RequestOptions({headers: headers}); return this.http.put(url, "", requestOptions); } public observable2(data1url): Observable<Response> {

Chain and merge 3 RxJS Observables with result dependences without nesting in TypeScript and Angular 4

蓝咒 提交于 2021-02-07 14:33:30
问题 I have 3 observables that i need to chain, result from first one is used in the other 2. They must run in order and each one must wait for the previous one to finish. Is it possible to chain then without nesting? public observable1(): Observable<Response> { let headers = new Headers(); headers.append("Content-Range", "bytes */*"); let requestOptions = new RequestOptions({headers: headers}); return this.http.put(url, "", requestOptions); } public observable2(data1url): Observable<Response> {

How can i subscribe to multiple observables in angular2 at once and wait, if there is new data on each of them?

半城伤御伤魂 提交于 2021-02-07 12:24:17
问题 i have a angular component, that uses 3 services. Each of those services has an observer, that i can subscribe to. The view of the component must be updated, if anything on the observed changes, that happens through websockets (feathers.js). I want the doSomethingWithTheNewDataThatIsShownOnView() to be called only once on ngInit and i think, i can do this with forkJoin: private ngOnInit(): void { Observable.forkJoin( this.filesService.inputs$, this.filesService.outputs$, this.processesService

Angular Firebase - merge two Observables into one

时间秒杀一切 提交于 2021-02-07 10:44:11
问题 Struggling a bit too long here. I have two tables in Firebase: accounts LJHGGKJH prop1: 'val' prop2: 'val' IUYIUTJF prop1: 'val' prop2: 'val' locations_per_account LJHGGKJH 0: [1, 5, 6] IUYIUTJF 0: [5, 2, 8] As you see accounts item's unique key points to locations_per_account item's unique key - if they match they belongs to the same user. Now I want to make one method in my service which would provide me observable of every account and its locations, so I could use async pipe in my template

Angular 6 observables - extract data from .subscribe() function and use it elsewhere

我的未来我决定 提交于 2021-02-07 03:27:51
问题 I'm banging my head against the wall with observables. Almost all of the documentation I can find is in the older rxjs syntax. I have an API call which is an observable. I'm calling it elsewhere and subscribing to it - trying to populate a table with the data from this GET request. If I simply console.log my getData function, it logs the subscription rather than my data. I can successfully console.log data within the .subscribe function, but I want to use data outside of .subscribe() . How do

Angular 6 observables - extract data from .subscribe() function and use it elsewhere

谁说我不能喝 提交于 2021-02-07 03:25:36
问题 I'm banging my head against the wall with observables. Almost all of the documentation I can find is in the older rxjs syntax. I have an API call which is an observable. I'm calling it elsewhere and subscribing to it - trying to populate a table with the data from this GET request. If I simply console.log my getData function, it logs the subscription rather than my data. I can successfully console.log data within the .subscribe function, but I want to use data outside of .subscribe() . How do

Angular 6 observables - extract data from .subscribe() function and use it elsewhere

廉价感情. 提交于 2021-02-07 03:24:21
问题 I'm banging my head against the wall with observables. Almost all of the documentation I can find is in the older rxjs syntax. I have an API call which is an observable. I'm calling it elsewhere and subscribing to it - trying to populate a table with the data from this GET request. If I simply console.log my getData function, it logs the subscription rather than my data. I can successfully console.log data within the .subscribe function, but I want to use data outside of .subscribe() . How do

What is the difference between Schedulers.io() and Schedulers.computation()

痴心易碎 提交于 2021-02-06 09:48:18
问题 I use Observables in couchbase. What is the difference between Schedulers.io() and Schedulers.computation() ? 回答1: From the documentation of rx: Schedulers.computation( ) - meant for computational work such as event-loops and callback processing; do not use this scheduler for I/O (use Schedulers.io( ) instead); the number of threads, by default, is equal to the number of processors Schedulers.io( ) - meant for I/O-bound work such as asynchronous performance of blocking I/O, this scheduler is

What is the difference between Schedulers.io() and Schedulers.computation()

不羁的心 提交于 2021-02-06 09:46:35
问题 I use Observables in couchbase. What is the difference between Schedulers.io() and Schedulers.computation() ? 回答1: From the documentation of rx: Schedulers.computation( ) - meant for computational work such as event-loops and callback processing; do not use this scheduler for I/O (use Schedulers.io( ) instead); the number of threads, by default, is equal to the number of processors Schedulers.io( ) - meant for I/O-bound work such as asynchronous performance of blocking I/O, this scheduler is

Unit testing that items get filtered out of Observable (Jasmine/RxJS)

北战南征 提交于 2021-02-05 05:30:07
问题 I'm doing unit testing with Jasmine/Karma against an Angular service. I'd like to confirm that my service properly filters items. For example, if I have a service to get people over a certain age, it should return people over the minimum age (positive case) should NOT return people under a the minimum age (negative case) It's #2 that I'm struggling to test. The service: getPeople(minAge: number): Observable<string> { const source = Observable.from([ { name: 'Joe', age: 30 }, { name: 'Frank',