Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observable-based queries re-emit lists matching previous queries #830

Closed
cartant opened this issue Feb 17, 2017 · 0 comments
Closed

Observable-based queries re-emit lists matching previous queries #830

cartant opened this issue Feb 17, 2017 · 0 comments

Comments

@cartant
Copy link
Contributor

cartant commented Feb 17, 2017

Version info

Angular: 2.4.7

Firebase: 3.6.9

AngularFire: 2.0.0-beta.8

Other (e.g. Ionic/Cordova, Node, browser, operating system): N/A

How to reproduce these conditions

There is a plunk here that demonstrates the bug.

Steps to set up and reproduce

Run the above plunk which:

  • sets up some initial content
  • runs an observable-based query to select odd numbers
  • re-runs the query to select even numbers
  • writes more data - including both an even and an odd number - to the database

Note that after more data is written, the list observable emits a list that matches the first (odd) query and then the second (even) query.

The bug is due to mergeMap - which is used here - the behaviour of which is to allow merged observables to continue to emit. switchMap should be used instead.

Expected behavior

When an observable query changes, the list observable should emit only lists that relate to the changed query.

Actual behavior

When an observable query changes, the list observable emits lists that relate to the changed query and any previous queries.

cartant added a commit to cartant/angularfire that referenced this issue Feb 17, 2017
cartant added a commit to cartant/angularfire that referenced this issue Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant