Angular firestore app queries with userId not working









up vote
1
down vote

favorite












I have an angular 6 with firebase application
I have a Service with an observable (i later want multiple subscribers listening to this same observable)
and also a component that subscribes to this observable
what im trying to achieve is to get the auth object, get the userId (UID) from it and search the db for all documents with this id



the component is calling the observable at the ngOnInit hook but at the stage its still null so i get




Cannot read property 'subscribe' of undefined




the problem is that if i run the code to fill the observable inside the subscribe block (to get the auth data) that i dont get to see the data, if its outside of it (running sync using static UID) than it does get filled correctly and shows data
here is the code for the service



import Injectable, EventEmitter from '@angular/core';
import AngularFirestore, AngularFirestoreCollection, DocumentChangeAction from '@angular/fire/firestore';
import Expense from '../model/Expense';
import Observable, ReplaySubject, Subject, from from 'rxjs';
import map from 'rxjs/operators';
import AuthService from '../core/services/auth.service';

@Injectable(
providedIn: 'root',
)
export class ExpenseService

private dbPath = '/expenses';

expenseDetailEvent: EventEmitter<Expense> = new EventEmitter<Expense>();

expensesRef: AngularFirestoreCollection<Expense> = null;
expenses$: Observable<Expense>;

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
,
error => console.log(error)
);


createExpense(expense: Expense): Observable<any>
return from(this.expensesRef.add(expense));


updateExpense(expense: Expense): Observable<any>
return from(this.expensesRef.doc(expense.id).update(expense));




and the component just does



ngOnInit() 
this.expenseService.expenses$.subscribe(expenses => this.expenses = expenses);



i noticed that all the examples on line, call this on the component, but i feel that the database call should be in a service in a similar way that its done with normal http api calls



UPDATE
if i initialize the service like this



expenses$: Observable<Expense> = of();


so of course the app doesnt crash, but i dont see any data
if i just pull the code outside and use static UID than it does... (of course user.uid is the same as the static string i pasted)



here is the updated code



constructor(private db: AngularFirestore, auth: AuthService) 
console.log('being here ,i see the data on screen using the static uid');
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', 'noYVScDtKfNB5aFqRkAJR7ghxio2')
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
auth.user$.subscribe(
user =>
console.log('if inside here than it will not show any data on screen');

,
error => console.log(error)
);










share|improve this question























  • did you try to use ngAfterViewInit()
    – Amir Fawzy
    Nov 9 at 17:36










  • I did, no effect, the problem is that the observable is being initialized after that
    – naoru
    Nov 9 at 17:49














up vote
1
down vote

favorite












I have an angular 6 with firebase application
I have a Service with an observable (i later want multiple subscribers listening to this same observable)
and also a component that subscribes to this observable
what im trying to achieve is to get the auth object, get the userId (UID) from it and search the db for all documents with this id



the component is calling the observable at the ngOnInit hook but at the stage its still null so i get




Cannot read property 'subscribe' of undefined




the problem is that if i run the code to fill the observable inside the subscribe block (to get the auth data) that i dont get to see the data, if its outside of it (running sync using static UID) than it does get filled correctly and shows data
here is the code for the service



import Injectable, EventEmitter from '@angular/core';
import AngularFirestore, AngularFirestoreCollection, DocumentChangeAction from '@angular/fire/firestore';
import Expense from '../model/Expense';
import Observable, ReplaySubject, Subject, from from 'rxjs';
import map from 'rxjs/operators';
import AuthService from '../core/services/auth.service';

@Injectable(
providedIn: 'root',
)
export class ExpenseService

private dbPath = '/expenses';

expenseDetailEvent: EventEmitter<Expense> = new EventEmitter<Expense>();

expensesRef: AngularFirestoreCollection<Expense> = null;
expenses$: Observable<Expense>;

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
,
error => console.log(error)
);


createExpense(expense: Expense): Observable<any>
return from(this.expensesRef.add(expense));


updateExpense(expense: Expense): Observable<any>
return from(this.expensesRef.doc(expense.id).update(expense));




and the component just does



ngOnInit() 
this.expenseService.expenses$.subscribe(expenses => this.expenses = expenses);



i noticed that all the examples on line, call this on the component, but i feel that the database call should be in a service in a similar way that its done with normal http api calls



UPDATE
if i initialize the service like this



expenses$: Observable<Expense> = of();


so of course the app doesnt crash, but i dont see any data
if i just pull the code outside and use static UID than it does... (of course user.uid is the same as the static string i pasted)



here is the updated code



constructor(private db: AngularFirestore, auth: AuthService) 
console.log('being here ,i see the data on screen using the static uid');
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', 'noYVScDtKfNB5aFqRkAJR7ghxio2')
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
auth.user$.subscribe(
user =>
console.log('if inside here than it will not show any data on screen');

,
error => console.log(error)
);










share|improve this question























  • did you try to use ngAfterViewInit()
    – Amir Fawzy
    Nov 9 at 17:36










  • I did, no effect, the problem is that the observable is being initialized after that
    – naoru
    Nov 9 at 17:49












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have an angular 6 with firebase application
I have a Service with an observable (i later want multiple subscribers listening to this same observable)
and also a component that subscribes to this observable
what im trying to achieve is to get the auth object, get the userId (UID) from it and search the db for all documents with this id



the component is calling the observable at the ngOnInit hook but at the stage its still null so i get




Cannot read property 'subscribe' of undefined




the problem is that if i run the code to fill the observable inside the subscribe block (to get the auth data) that i dont get to see the data, if its outside of it (running sync using static UID) than it does get filled correctly and shows data
here is the code for the service



import Injectable, EventEmitter from '@angular/core';
import AngularFirestore, AngularFirestoreCollection, DocumentChangeAction from '@angular/fire/firestore';
import Expense from '../model/Expense';
import Observable, ReplaySubject, Subject, from from 'rxjs';
import map from 'rxjs/operators';
import AuthService from '../core/services/auth.service';

@Injectable(
providedIn: 'root',
)
export class ExpenseService

private dbPath = '/expenses';

expenseDetailEvent: EventEmitter<Expense> = new EventEmitter<Expense>();

expensesRef: AngularFirestoreCollection<Expense> = null;
expenses$: Observable<Expense>;

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
,
error => console.log(error)
);


createExpense(expense: Expense): Observable<any>
return from(this.expensesRef.add(expense));


updateExpense(expense: Expense): Observable<any>
return from(this.expensesRef.doc(expense.id).update(expense));




and the component just does



ngOnInit() 
this.expenseService.expenses$.subscribe(expenses => this.expenses = expenses);



i noticed that all the examples on line, call this on the component, but i feel that the database call should be in a service in a similar way that its done with normal http api calls



UPDATE
if i initialize the service like this



expenses$: Observable<Expense> = of();


so of course the app doesnt crash, but i dont see any data
if i just pull the code outside and use static UID than it does... (of course user.uid is the same as the static string i pasted)



here is the updated code



constructor(private db: AngularFirestore, auth: AuthService) 
console.log('being here ,i see the data on screen using the static uid');
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', 'noYVScDtKfNB5aFqRkAJR7ghxio2')
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
auth.user$.subscribe(
user =>
console.log('if inside here than it will not show any data on screen');

,
error => console.log(error)
);










share|improve this question















I have an angular 6 with firebase application
I have a Service with an observable (i later want multiple subscribers listening to this same observable)
and also a component that subscribes to this observable
what im trying to achieve is to get the auth object, get the userId (UID) from it and search the db for all documents with this id



the component is calling the observable at the ngOnInit hook but at the stage its still null so i get




Cannot read property 'subscribe' of undefined




the problem is that if i run the code to fill the observable inside the subscribe block (to get the auth data) that i dont get to see the data, if its outside of it (running sync using static UID) than it does get filled correctly and shows data
here is the code for the service



import Injectable, EventEmitter from '@angular/core';
import AngularFirestore, AngularFirestoreCollection, DocumentChangeAction from '@angular/fire/firestore';
import Expense from '../model/Expense';
import Observable, ReplaySubject, Subject, from from 'rxjs';
import map from 'rxjs/operators';
import AuthService from '../core/services/auth.service';

@Injectable(
providedIn: 'root',
)
export class ExpenseService

private dbPath = '/expenses';

expenseDetailEvent: EventEmitter<Expense> = new EventEmitter<Expense>();

expensesRef: AngularFirestoreCollection<Expense> = null;
expenses$: Observable<Expense>;

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
,
error => console.log(error)
);


createExpense(expense: Expense): Observable<any>
return from(this.expensesRef.add(expense));


updateExpense(expense: Expense): Observable<any>
return from(this.expensesRef.doc(expense.id).update(expense));




and the component just does



ngOnInit() 
this.expenseService.expenses$.subscribe(expenses => this.expenses = expenses);



i noticed that all the examples on line, call this on the component, but i feel that the database call should be in a service in a similar way that its done with normal http api calls



UPDATE
if i initialize the service like this



expenses$: Observable<Expense> = of();


so of course the app doesnt crash, but i dont see any data
if i just pull the code outside and use static UID than it does... (of course user.uid is the same as the static string i pasted)



here is the updated code



constructor(private db: AngularFirestore, auth: AuthService) 
console.log('being here ,i see the data on screen using the static uid');
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', 'noYVScDtKfNB5aFqRkAJR7ghxio2')
);
this.expenses$ = this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
);
auth.user$.subscribe(
user =>
console.log('if inside here than it will not show any data on screen');

,
error => console.log(error)
);







angular firebase google-cloud-firestore angular6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 18:22

























asked Nov 9 at 17:11









naoru

67011835




67011835











  • did you try to use ngAfterViewInit()
    – Amir Fawzy
    Nov 9 at 17:36










  • I did, no effect, the problem is that the observable is being initialized after that
    – naoru
    Nov 9 at 17:49
















  • did you try to use ngAfterViewInit()
    – Amir Fawzy
    Nov 9 at 17:36










  • I did, no effect, the problem is that the observable is being initialized after that
    – naoru
    Nov 9 at 17:49















did you try to use ngAfterViewInit()
– Amir Fawzy
Nov 9 at 17:36




did you try to use ngAfterViewInit()
– Amir Fawzy
Nov 9 at 17:36












I did, no effect, the problem is that the observable is being initialized after that
– naoru
Nov 9 at 17:49




I did, no effect, the problem is that the observable is being initialized after that
– naoru
Nov 9 at 17:49












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










The issue is that the expenses$ Observable will be defined only after the auth.user$ has emitted something, because then is when it gets assigned.



Solution 1
You could try injecting ExpenseService service in the constructor of a higher level component, maybe even AppComponent, so that the ExpenseService's constructor gets called and the expenses$ Observable gets assigned (you just need to inject it, without any method call or property access). At this point by the time you load the component the Observable should be defined



Solution 2
Manually create the Observable expenses$ using of and then subscribing to this.expensesRef.snapshotChanges() you can emit values back in expenses$



Something like:



...

expensesSubject = new Subject<Expense>();
expenses$: from(expensesSubject);

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
).subscribe((whatever) =>
expensesSubject.next(whatever);
)

)






share|improve this answer






















  • Can you elaborate a bit on solution 2
    – naoru
    Nov 9 at 18:06










  • I edited the answer to show the problem
    – naoru
    Nov 9 at 18:23










  • I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
    – Massimiliano Sartoretto
    Nov 9 at 18:27










  • bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
    – naoru
    Nov 9 at 18:34










  • Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
    – Massimiliano Sartoretto
    Nov 9 at 18:40










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230394%2fangular-firestore-app-queries-with-userid-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










The issue is that the expenses$ Observable will be defined only after the auth.user$ has emitted something, because then is when it gets assigned.



Solution 1
You could try injecting ExpenseService service in the constructor of a higher level component, maybe even AppComponent, so that the ExpenseService's constructor gets called and the expenses$ Observable gets assigned (you just need to inject it, without any method call or property access). At this point by the time you load the component the Observable should be defined



Solution 2
Manually create the Observable expenses$ using of and then subscribing to this.expensesRef.snapshotChanges() you can emit values back in expenses$



Something like:



...

expensesSubject = new Subject<Expense>();
expenses$: from(expensesSubject);

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
).subscribe((whatever) =>
expensesSubject.next(whatever);
)

)






share|improve this answer






















  • Can you elaborate a bit on solution 2
    – naoru
    Nov 9 at 18:06










  • I edited the answer to show the problem
    – naoru
    Nov 9 at 18:23










  • I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
    – Massimiliano Sartoretto
    Nov 9 at 18:27










  • bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
    – naoru
    Nov 9 at 18:34










  • Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
    – Massimiliano Sartoretto
    Nov 9 at 18:40














up vote
1
down vote



accepted










The issue is that the expenses$ Observable will be defined only after the auth.user$ has emitted something, because then is when it gets assigned.



Solution 1
You could try injecting ExpenseService service in the constructor of a higher level component, maybe even AppComponent, so that the ExpenseService's constructor gets called and the expenses$ Observable gets assigned (you just need to inject it, without any method call or property access). At this point by the time you load the component the Observable should be defined



Solution 2
Manually create the Observable expenses$ using of and then subscribing to this.expensesRef.snapshotChanges() you can emit values back in expenses$



Something like:



...

expensesSubject = new Subject<Expense>();
expenses$: from(expensesSubject);

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
).subscribe((whatever) =>
expensesSubject.next(whatever);
)

)






share|improve this answer






















  • Can you elaborate a bit on solution 2
    – naoru
    Nov 9 at 18:06










  • I edited the answer to show the problem
    – naoru
    Nov 9 at 18:23










  • I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
    – Massimiliano Sartoretto
    Nov 9 at 18:27










  • bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
    – naoru
    Nov 9 at 18:34










  • Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
    – Massimiliano Sartoretto
    Nov 9 at 18:40












up vote
1
down vote



accepted







up vote
1
down vote



accepted






The issue is that the expenses$ Observable will be defined only after the auth.user$ has emitted something, because then is when it gets assigned.



Solution 1
You could try injecting ExpenseService service in the constructor of a higher level component, maybe even AppComponent, so that the ExpenseService's constructor gets called and the expenses$ Observable gets assigned (you just need to inject it, without any method call or property access). At this point by the time you load the component the Observable should be defined



Solution 2
Manually create the Observable expenses$ using of and then subscribing to this.expensesRef.snapshotChanges() you can emit values back in expenses$



Something like:



...

expensesSubject = new Subject<Expense>();
expenses$: from(expensesSubject);

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
).subscribe((whatever) =>
expensesSubject.next(whatever);
)

)






share|improve this answer














The issue is that the expenses$ Observable will be defined only after the auth.user$ has emitted something, because then is when it gets assigned.



Solution 1
You could try injecting ExpenseService service in the constructor of a higher level component, maybe even AppComponent, so that the ExpenseService's constructor gets called and the expenses$ Observable gets assigned (you just need to inject it, without any method call or property access). At this point by the time you load the component the Observable should be defined



Solution 2
Manually create the Observable expenses$ using of and then subscribing to this.expensesRef.snapshotChanges() you can emit values back in expenses$



Something like:



...

expensesSubject = new Subject<Expense>();
expenses$: from(expensesSubject);

constructor(private db: AngularFirestore, auth: AuthService)
auth.user$.subscribe(
user =>
this.expensesRef = this.db.collection<Expense>(this.dbPath, ref =>
ref.where('clientId', '==', user.uid)
);
this.expensesRef.snapshotChanges().pipe(
map(actions =>
actions.map(a =>
const data = a.payload.doc.data() as Expense;
const id = a.payload.doc.id;
return id, ...data ;
)
)
).subscribe((whatever) =>
expensesSubject.next(whatever);
)

)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 9 at 18:26

























answered Nov 9 at 18:03









Massimiliano Sartoretto

31618




31618











  • Can you elaborate a bit on solution 2
    – naoru
    Nov 9 at 18:06










  • I edited the answer to show the problem
    – naoru
    Nov 9 at 18:23










  • I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
    – Massimiliano Sartoretto
    Nov 9 at 18:27










  • bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
    – naoru
    Nov 9 at 18:34










  • Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
    – Massimiliano Sartoretto
    Nov 9 at 18:40
















  • Can you elaborate a bit on solution 2
    – naoru
    Nov 9 at 18:06










  • I edited the answer to show the problem
    – naoru
    Nov 9 at 18:23










  • I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
    – Massimiliano Sartoretto
    Nov 9 at 18:27










  • bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
    – naoru
    Nov 9 at 18:34










  • Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
    – Massimiliano Sartoretto
    Nov 9 at 18:40















Can you elaborate a bit on solution 2
– naoru
Nov 9 at 18:06




Can you elaborate a bit on solution 2
– naoru
Nov 9 at 18:06












I edited the answer to show the problem
– naoru
Nov 9 at 18:23




I edited the answer to show the problem
– naoru
Nov 9 at 18:23












I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
– Massimiliano Sartoretto
Nov 9 at 18:27




I edited the answer, typings might need to be checked but you get the idea. In the component keep everything as it is.
– Massimiliano Sartoretto
Nov 9 at 18:27












bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
– naoru
Nov 9 at 18:34




bravo, it worked but i didn't quite understand why before it wasn't working and if its necessary to use both (expenses$ and expensesSubject)
– naoru
Nov 9 at 18:34












Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
– Massimiliano Sartoretto
Nov 9 at 18:40




Not necessary but a good practice. Usually you want to keep expensesSubject marked as private to the service and then expenses$ as public. This avoid components or other services being able to emit data in the stream.
– Massimiliano Sartoretto
Nov 9 at 18:40

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230394%2fangular-firestore-app-queries-with-userid-not-working%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)