rxjs

Angular 4 loading tree structure in recursive observable calls

╄→尐↘猪︶ㄣ 提交于 2021-02-07 18:32:32
问题 Hi I'm pretty new to Observables and I'm looking for a way of loading my navigation tree with recursive observable calls. The Navigation should be build up dynamically base on all the index.json files in the directory and sub directories. Only the url of the first call is static: /public/index.json This is the directory structure. Each directory may contain a index.json , providing information about its content and may references to other index files via the loadChildrenFromUrl property. |

Angular 4 loading tree structure in recursive observable calls

天涯浪子 提交于 2021-02-07 18:32:07
问题 Hi I'm pretty new to Observables and I'm looking for a way of loading my navigation tree with recursive observable calls. The Navigation should be build up dynamically base on all the index.json files in the directory and sub directories. Only the url of the first call is static: /public/index.json This is the directory structure. Each directory may contain a index.json , providing information about its content and may references to other index files via the loadChildrenFromUrl property. |

Using RxJs groupBy with objects as keys

六月ゝ 毕业季﹏ 提交于 2021-02-07 14:51:16
问题 I'm trying to use groupBy with RxJs, and I need to use objects as keys. If I don't and I use, for example, simple strings like this: var types = stream.groupBy( function (e) { return e.x; }); //x is a string then everything goes fine and my subscription is called once, and once only, for each different key. But if I try with objects, the subscription is called for each element from stream , even if a key happens to be the same as previous ones. There is of course a problem about object

Using RxJs groupBy with objects as keys

天涯浪子 提交于 2021-02-07 14:49:26
问题 I'm trying to use groupBy with RxJs, and I need to use objects as keys. If I don't and I use, for example, simple strings like this: var types = stream.groupBy( function (e) { return e.x; }); //x is a string then everything goes fine and my subscription is called once, and once only, for each different key. But if I try with objects, the subscription is called for each element from stream , even if a key happens to be the same as previous ones. There is of course a problem about object

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 to test multiple sequential calls with Jasmine

时光毁灭记忆、已成空白 提交于 2021-02-07 12:56:39
问题 I am trying to test a function that unsubscribes from all subscriptions: ngOnDestroy() { this.tryUnsubscribe(this.carsSubscription); this.tryUnsubscribe(this.partsSubscription); this.tryUnsubscribe(this.shopsSubscription); } This is the test I wrote for the function: it('should unsubscribe from subscriptions ', () => { spyOn(component, "tryUnsubscribe"); component.ngOnDestroy(); expect(component.tryUnsubscribe).toHaveBeenCalledWith(component['carsSubscription']); expect(component

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

Generic type Subject<T> requires 1 type argument(s). - Angular

泄露秘密 提交于 2021-02-07 11:46:15
问题 I'm getting data from my service and I've red about it's important to unsubscribe after subscribe, and here is how I did it: export class RItemComponent implements OnInit { apiPath = environment.apiUrl; private ngUnsubscribe: Subject = new Subject(); constructor(private _sharedService: SharedService) { } rItems: Product[]; ngOnInit() { this._sharedService. getReceiptItem().takeUntil(this.ngUnsubscribe). subscribe(products => this.rItems = products); } ngOnDestroy() { this.ngUnsubscribe.next()

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