Repository navigation
Description
Version info
Angular: 7.1.3
Firebase: 5.7.0
**AngularFire:**5.1.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
How to reproduce these conditions
Failing test unit, Plunkr, or JSFiddle demonstrating the problem
No plunker possible
Steps to set up and reproduce
- In my service I have a call to a collection query by multiple where clauses and return back a single observable.
public getStreams(eventID: string, activityID: string, types: string[]): Observable<StreamInterface[]> {
return combineLatest.apply(this, types.map((type) => {
return this.afs
.collection('events')
.doc(eventID)
.collection('activities')
.doc(activityID)
.collection('streams', ref => ref.where('type', '==', type))
.snapshotChanges()
.pipe(map((streamSnapshots) => { // @todo should be reduce
return this.processStreamSnapshots(streamSnapshots)[0] // Get the first element of the return
})) // since the return with equality on the query should only fetch one afaik in my model
})).pipe(map((streams: StreamInterface[]) => {
return streams.filter((stream) => !!stream)
}))
- Then I have some other call that fetches everything from that collection
public getAllStreams(eventID: string, activityID: string): Observable<StreamInterface[]> {
return this.afs
.collection('events')
.doc(eventID)
.collection('activities')
.doc(activityID)
.collection('streams')
.snapshotChanges()
.pipe(map((streamSnapshots) => {
debugger;
return this.processStreamSnapshots(streamSnapshots);
}))
}
I am calling and subscribing first on the multiple where query of my service eg:
this.streamsSubscriptions.push(this.eventService.getStreams(this.event.getID(), activity.getID(), [DataLatitudeDegrees.type, DataLongitudeDegrees.type])
Than at some point later I subscribe also to the "all" list
this.eventService.getAllStreams(this.event.getID(), activity.getID());
However the 'all' call gets triggered 2 times.
One it returns the results of the:
this.streamsSubscriptions.push(this.eventService.getStreams(this.event.getID(), activity.getID(), [DataLatitudeDegrees.type, DataLongitudeDegrees.type])
... which in my logic is an array of 2
And the second time it returns as expected all the results. (Array of lets say 20)
What am I missing or is this a bug
I would expect only one call with just all the results
Sample data and security rules
No data
Debug output
** Errors in the JavaScript console **
** Output from firebase.database().enableLogging(true); **
** Screenshots **
Expected behavior
See description
Actual behavior
See description
Activity
jek-bao-choo commentedon Mar 22, 2019
same here. experiencing this problem.
phihochzwei commentedon Apr 30, 2019
We are facing the exact same problem here. Anyone a solution for this?
jimmykane commentedon Apr 30, 2019
See
The comment there on the above block.
In short use get to ensure
jamesdaniels commentedon Nov 18, 2020
I'm not exactly clear what this issue is? Does it remain or is this outdated. Closing for now but will reopen if still exists.