Angularfire: Invalid object with afDb.object.valueChanges in switchMap

Created on 23 Jun 2018  路  4Comments  路  Source: angular/angularfire

Version info

*Angular: ~6.0.0
*
Firebase: 5.0.4 and 5.1.0
*AngularFire: ^5.0.0-rc.11
*
Rxjs: 6.2.1

The observable returned by AngularFireDatabase can't be returned by switchMap operator's callback.
I tried a few combinations of versions and I figured out that this bug is only produced with Firebase 5.0.4 and above.

I don't get this error with :
Angular 6.0.0 to 6.0.6
Firebase 5.0.3
AngularFire 5.0.0-rc.9 to 5.0.0-rc.11
Rxjs 6.0.0 to 6.2.1

How to reproduce these conditions

Steps to set up and reproduce

-ng new
-install Firebase and AngularFire

of(true).pipe(switchMap(() => this.afDb.object('anyRef').valueChanges())).subscribe()

Debug output

ERROR TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at Object.push../node_modules/rxjs/internal/util/subscribeTo.js.exports.subscribeTo (subscribeTo.js:42)
at Object.subscribeToResult (subscribeToResult.js:7)
at SwitchMapSubscriber.push../node_modules/rxjs/internal/operators/switchMap.js.SwitchMapSubscriber._innerSub (switchMap.js:58)
at SwitchMapSubscriber.push../node_modules/rxjs/internal/operators/switchMap.js.SwitchMapSubscriber._next (switchMap.js:51)
at SwitchMapSubscriber.push../node_modules/rxjs/internal/Subscriber.js.Subscriber.next (Subscriber.js:64)
at MapSubscriber.push../node_modules/rxjs/internal/operators/map.js.MapSubscriber._next (map.js:52)
at MapSubscriber.push../node_modules/rxjs/internal/Subscriber.js.Subscriber.next (Subscriber.js:64)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:38)

Most helpful comment

Just ran into this issue also with another dev, where are you importing switchmap and of from? check that it's rxjs and rxjs/operators

All 4 comments

@jgan42 Can you create a stackblitz to recreate the problem so I can debug?

Just ran into this issue also with another dev, where are you importing switchmap and of from? check that it's rxjs and rxjs/operators

Hi,

The auto import gave me this :
import {switchMap} from 'rxjs/internal/operators';

effectively it works well with :
import {switchMap} from 'rxjs/operators';
Tested with firebase 5.0.4 to 5.2.0.

My bad, thanks for your time.

Oi,

A importa莽茫o autom谩tica me deu isto:
import {switchMap} from 'rxjs/internal/operators';

efetivamente funciona bem com:
import {switchMap} from 'rxjs/operators';
Testado com firebase 5.0.4 a 5.2.0.

Meu mal, obrigado pelo seu tempo.

Perfect!!!!

Tks!!! :)

Was this page helpful?
0 / 5 - 0 ratings