Reputation: 1610
Version info
Angular: 7 / Firebase: 5.7.3 / AngularFire: 5.1.1
I tried to implement HttpInterceptor on angularfire2/Firestore API calls (Request URL: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects....) without success.
The requests are not crossing the Interceptor as @angular/common/http/HttpClient is not used.
Is there any workaround to integrate the Angular Interceptor functionality on those API calls?
Thank you
Upvotes: 0
Views: 797
Reputation: 1310
As far as i know AngularFire is a Angular friendly wrapper for the Firebase SDK.
The Firebase SDK does not use Angular Http Client so API calls from the SDK can not be intercepted.
For what use case do you want to intercept Firebase API calls?
Edit:
Here is a pseudo code example how i implement a simple loading spinner.
On the event which starts the Firestore operation you could set isLoading
to true and as soon as you get the response from Firestore you could set isLoading
to fasle.
In your template you could display a loading spinner with *ngIf
.
component.ts
this.isLoading = false;
onEvent() {
this.isLoading = true;
this.angularFirestore.collection('test').doc('testId').set(data)
.subscribe(
success => {
this.isLoading = false;
}
error => {
console.log(error);
this.isLoading = false;
}
);
}
component.html
<div *ngIf="isLoading">
<loading-spinner>
</div>
Upvotes: 1