HttpInterceptor无法与angularfire2/Firestore API调用一起使用.任何解决方法?

编程入门 行业动态 更新时间:2024-10-21 11:42:08
本文介绍了HttpInterceptor无法与angularfire2/Firestore API调用一起使用.任何解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

版本信息

角度:7/火力:5.7.3/AngularFire:5.1.1

我尝试在angularfire2/Firestore API调用上实现HttpInterceptor(请求URL: firestore.googleapis/google.firestore.v1.Firestore/Listen/channel?database = projects ... .),但不会成功.

I tried to implement HttpInterceptor on angularfire2/Firestore API calls (Request URL: firestore.googleapis/google.firestore.v1.Firestore/Listen/channel?database=projects....) without success.

由于未使用@ angular/common/http/HttpClient,因此请求没有越过拦截器.

The requests are not crossing the Interceptor as @angular/common/http/HttpClient is not used.

有没有解决方法可以在这些API调用上集成Angular Interceptor功能?

Is there any workaround to integrate the Angular Interceptor functionality on those API calls?

谢谢

推荐答案

据我所知,AngularFire是Firebase SDK的Angular友好包装器.

As far as i know AngularFire is a Angular friendly wrapper for the Firebase SDK.

Firebase SDK不使用Angular Http Client,因此无法拦截来自SDK的API调用.

The Firebase SDK does not use Angular Http Client so API calls from the SDK can not be intercepted.

您想在什么用例中拦截Firebase API调用?

For what use case do you want to intercept Firebase API calls?

这是一个伪代码示例,说明我如何实现一个简单的加载微调器.

Here is a pseudo code example how i implement a simple loading spinner.

在启动Firestore操作的事件上,您可以将 isLoading 设置为true,一旦收到Firestore的响应,就可以将 isLoading 设置为fasle.

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.

在模板中,您可以显示带有 * ngIf 的加载微调器.

In your template you could display a loading spinner with *ngIf.

component.ts

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

component.html

<div *ngIf="isLoading"> <loading-spinner> </div>

更多推荐

HttpInterceptor无法与angularfire2/Firestore API调用一起使用.任何解决方法?

本文发布于:2023-05-28 12:31:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/320956.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file &#039;D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!