observable

Angular and Firestore: FirebaseError: Missing or insufficient permissions. How add idToken while observing a specific document

一曲冷凌霜 提交于 2020-05-16 22:06:24
问题 I code the code bellow that is notified in real time manner. I mean it keeps observing and soon any collection fields are updated it is loaded in Angular page. app.component.ts import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { AngularFirestore } from '@angular/fire/firestore'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { public transfers: Observable<any[]>; constructor(db: AngularFirestore) { this

Angular and Firestore: FirebaseError: Missing or insufficient permissions. How add idToken while observing a specific document

余生长醉 提交于 2020-05-16 22:05:33
问题 I code the code bellow that is notified in real time manner. I mean it keeps observing and soon any collection fields are updated it is loaded in Angular page. app.component.ts import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { AngularFirestore } from '@angular/fire/firestore'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { public transfers: Observable<any[]>; constructor(db: AngularFirestore) { this

Why Aren't FormControl#valueChanges' Subscriptions Garbage Collected?

北城以北 提交于 2020-05-13 07:10:35
问题 I have gone through plenty of threads saying that one needs to unsubscribe from FormControl#valueChanges to prevent memory leaks. I understood the "when" and "how" to unsubscribe from Observable s. As I understand, Observables that produce infinite number of values need to be unsubscribed and FormControl#valueChanges is one such Observable . But my question is, why aren't these Observables s garbage collected? I mean when an Angular component gets destroyed, the references are dead right? The

Why Aren't FormControl#valueChanges' Subscriptions Garbage Collected?

心已入冬 提交于 2020-05-13 07:10:30
问题 I have gone through plenty of threads saying that one needs to unsubscribe from FormControl#valueChanges to prevent memory leaks. I understood the "when" and "how" to unsubscribe from Observable s. As I understand, Observables that produce infinite number of values need to be unsubscribed and FormControl#valueChanges is one such Observable . But my question is, why aren't these Observables s garbage collected? I mean when an Angular component gets destroyed, the references are dead right? The

SwitchMap operator with an array

跟風遠走 提交于 2020-05-12 04:54:48
问题 I'm trying to learn rxjs and the Observable concept in general and have a scenario where I have a class of <Room>{} where <Player>{} can join in many-to-many relationship style. In Firestore I have collection of rooms where each room has a property called players which is an array of user uid s. When a rooms component is created I subscribe to _roomService.getPlayersInRoom(roomId) which looks like below: getPlayersInRoom(roomId: string) { return this._db.doc<Room>(`rooms/${roomId}`)

Why does repeated Enumerable to Observable conversion block

孤街浪徒 提交于 2020-05-09 02:48:22
问题 This is a rather educational, out of curiosity question. Consider the following snippet: var enumerable = Enumerable.Range(0, 5); var observable = enumerable.ToObservable(); var enu = observable.Concat(observable).ToEnumerable(); enu.ToObservable().SubscribeDebug(); Where SubscribeDebug subscribes a simple observer: public class DebugObserver<T> : IObserver<T> { public void OnCompleted() { Debug.WriteLine("Completed"); } public void OnError(Exception error) { Debug.WriteLine("Error"); }

Return promise value from observable subsciption

孤人 提交于 2020-04-30 05:57:25
问题 Is there any chance to return from helpMe function value from getDataFromApi() ? So far every time i call this function i get "null" value. async function helpMe() { let promise = null; let sub = someService.someObservable.subscribe(async () => { promise = await getDataFromApi() }) subscriptions.push(sub) return promise; } The first goal is i need to store subscription in global sub array. The second goal is when i get response with status 400 - I dont want to open modal. Only when i get 200

Return promise value from observable subsciption

女生的网名这么多〃 提交于 2020-04-30 05:56:25
问题 Is there any chance to return from helpMe function value from getDataFromApi() ? So far every time i call this function i get "null" value. async function helpMe() { let promise = null; let sub = someService.someObservable.subscribe(async () => { promise = await getDataFromApi() }) subscriptions.push(sub) return promise; } The first goal is i need to store subscription in global sub array. The second goal is when i get response with status 400 - I dont want to open modal. Only when i get 200

RxSwift - how to chain observables sequentially

烂漫一生 提交于 2020-04-29 10:00:32
问题 Assume I have array of Ints: var items = [1, 2, 3, 4, 5] and a function that takes Int argument and basing on it sends network request: func sendRequest(argument: Int) -> Observable<Void> { // sends network request ... } I want to send network requests for each element of items array, but I want to do it sequentially, send next request only once previous one is finished. My first attempt was something like this: let observables = items.map{ [weak self] argument in (self?.sendRequest(argument:

RxJava introduced Single<T>. How do I convert an Observable<T> to a Single<T>?

岁酱吖の 提交于 2020-04-29 07:18:07
问题 RxJava recently introduced Single. Is there a way to convert an already existing Observable (that's pretty much a Single) to a Single without modifying the source of the original observable? For example, I have an api service class with a method that returns an Observable - which is essentially fetching a User from a remote resource. Say I can't modify the service. I want to consume this elsewhere but return a Single. How do I do this? A pinch more background RxJava recently introduced the