Angular/rxjs:为什么我不必再导入 toPromise 了? [英] Angular/rxjs: Why don't I have to import toPromise anymore?

查看:28
本文介绍了Angular/rxjs:为什么我不必再导入 toPromise 了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大量的SO答案都说为了避免像

A ton of SO answers say that to avoid problems like

'Observable' 类型不存在属性 'toPromise'

Property 'toPromise' does not exist on type 'Observable'

在 Angular 中,您必须导入我直到最近才完成的rxjs/add/operator/toPromise".在 Angular 4.2.4 项目中,我忘记了导入并希望看到错误.它不存在!我在 Chrome 的开发工具中进行了一些调试,并在 Observable 的原型上看到了toPromise".

in Angular, you have to import 'rxjs/add/operator/toPromise' which I've done until recently. In an Angular 4.2.4 project, I forgot the import and expected to see an error. It wasn't there! I did some debugging in Chrome's dev tools and saw "toPromise" on the Observable's prototype.

我的问题是......它是如何到达那里的?这是 TypeScript、Angular 还是 rxjs 的新增功能?

My question is ... how did that get there? Is this a new addition to TypeScript, Angular, or rxjs?

推荐答案

As of rxjs 5.5.0-beta.5

As of rxjs 5.5.0-beta.5

toPromise:现在作为 Observable (2e49a5c) 上的永久方法存在

toPromise: now exists as a permanent method on Observable (2e49a5c)

https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#550-beta5-2017-10-06

这篇关于Angular/rxjs:为什么我不必再导入 toPromise 了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆