When I try to subscribe an AngularFireList in Angular 5/Firebase5 application giving the following error.
zone.js:192 Uncaught TypeError: Object(...) is not a function
at SwitchMapSubscriber.eval [as project] (changes.js:7)
at SwitchMapSubscriber._next (switchMap.js:91)
at SwitchMapSubscriber.Subscriber.next (Subscriber.js:95)
at RefCountSubscriber.Subscriber._next (Subscriber.js:131)
at RefCountSubscriber.Subscriber.next (Subscriber.js:95)
at Subject.next (Subject.js:56)
at ConnectableSubscriber.Subscriber._next (Subscriber.js:131)
at ConnectableSubscriber.Subscriber.next (Subscriber.js:95)
at Notification.observe (Notification.js:32)
at AsyncAction.DelaySubscriber.dispatch (delay.js:91)
My Service and Controller class content as follows,
1) Service named 'FirebaseService'
customers: AngularFireList<any>;
getCustomers(){
this.customers = this.fire.list('users');
return this.customers;
}
2) Controller
constructor(private firebase: FirebaseService) { }
serviceProviders: ServiceProvider[];
var x = this.firebase.getServiceProviders();
x.snapshotChanges().subscribe(item => {
this.serviceProviders = [];
item.forEach(element => {
var y = element.payload.toJSON();
y["$key"] = element.key;
this.serviceProviders.push(y as ServiceProvider);
});
});
Recent releases of AngularFire require rxjs 6. Please upgrade rxjs and include rxjs-compat
if you have dependencies that haven't upgraded.
I had a similar problem while using AngularFireList.valueChanges() there is an npm warning when you install recent release of AngularFire (5.0.0-rc.10)
npm WARN [email protected] requires a peer of rxjs@^6.0.0 but none is installed
so I have installed that dependency
npm install rxjs@^6.0.0 --save
in my project
It is also necessary to install the following dependency.
npm install --save rxjs-compat
and the problem is solved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With