Empty subscribe on valueChanges in Angular2

匆匆过客 提交于 2019-12-12 12:45:25

问题


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 {}

Why can't I leave the subscribe() empty?


回答1:


You probably have a older version of RxJS 5. This was a bug but is already fixed.

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

Otherwise, show what exact RxJS version you're using.



来源:https://stackoverflow.com/questions/45608374/empty-subscribe-on-valuechanges-in-angular2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!