safari - RxJS .pipe 在 Safari 上无法正常工作
问题描述
目前我有一个使用 Angular 8 和 RxJS 6.5.2 的实现,可以在 Google Chrome 上完美运行,但在 Safari 中它返回一个对我来说毫无意义的错误。下面我将分享这个实现的一个片段:
public getLoggedEmployee(): Observable<any> {
if (this.employee) {
return of(this.employee);
}
return this.authenticationService
.getAuthenticatedUser()
.pipe(
tap(user => this.authUser = user),
flatMap(user => this.findOneById(user.id)),
map((employee) => {
this.employee = _.merge(employee.data, { user: this.authUser });
return this.employee;
})
);
}
我怎么说,在 Chrome 中工作正常,但在 Safari 中我有这个错误:
Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'user.id')
由于某种原因,仍然undefinedflatMap
的值,我无法想象为什么。我检查了项目的 compilerOption 目标,目前正在使用,检查了一些缺少的 Safari 的 polyfill,但到目前为止还没有运气。user
es5
如果有人有任何想法可以帮助我找到解决方案,我将不胜感激。谢谢。
解决方案
在我的 Safari 中没问题(Catalina 10.15.4,Safari 13.1 15609.1.20.111.8)。
如何返回一个模拟数据(如of({ id: 1 })
)getAuthenticatedUser
?错误还会出现吗?
推荐阅读
- excel - VBA连接来自数据转储的多个范围
- java - 未找到 AbstractReactiveCouchbaseConfiguration
- r - 如何将 ggplot 用于一个绘图图形中的多行
- json - 如何使用 ansible 编写 json 文件
- bash - 更新 bash 脚本中的变量
- python - Tkinter 使用 grid_configure 调整标签大小
- html - 使用 beautifulsoup 进行数据抓取
- c# - 让picturebox每5分钟随机出现一次,如果玩家没有杀死它,它会在穿过游戏屏幕后消失
- r - 如何生成组合列表?
- sql - 您如何将昵称(pete、andy、Nick、Rob)映射到真实姓名?