简体   繁体   English

在Angular2中对valueChanges进行空订阅

[英]Empty subscribe on valueChanges in Angular2

I have this weird case, a subscribe that never fires if left empty. 我有这个奇怪的情况,订阅如果留空则永远不会触发。

This doesn't work: 这不起作用:

this.formGroup.get('unitCount').valueChanges
.do(value => console.log(value))
.subscribe();

When this works fine: 当这工作正常:

this.formGroup.get('unitCount').valueChanges
.do(value => console.log(value))
.subscribe(() => true);

Here I used () => true , but it could anything, false , void 0 , even an empty object {} 在这里我使用()=> true ,但它可以是任何东西, falsevoid 0 ,甚至是空对象{}

Why can't I leave the subscribe() empty? 为什么我不能将subscribe()留空?

You probably have a older version of RxJS 5. This was a bug but is already fixed. 你可能有一个旧版本的RxJS 5.这是一个错误,但已经修复。

I can't find since what version it works correctly, but this PR could be related to this: https://github.com/ReactiveX/rxjs/pull/1935 我无法找到它正常工作的版本,但这个PR可能与此有关: https//github.com/ReactiveX/rxjs/pull/1935

Otherwise, show what exact RxJS version you're using. 否则,显示您正在使用的RxJS版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM