Rxjs Subject next or onNext

自古美人都是妖i 提交于 2019-12-22 04:06:31

问题


I'm quite new at rxjs stuff be patience. For example in this tutorial http://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/ but I saw the same code in the ng-book

I can see

let subject = new Rx.Subject();
subject.subscribe(value => console.log('Received new subject value: '))
subject.next(newValue);

but if I put the code in the browser I've got

subject.next is not a function

so if I take a look to the doc https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/subjects.md

var subject = new Rx.Subject();
subject.subscribe(value => console.log('Received new subject value: ',value))
subject.onNext(2);

Can you explain me why the tutorial and the book are using next ? What am I missing ?


回答1:


Seems you're using the wrong rxjs version (4.x). Angular2 uses rxjs 5 https://github.com/ReactiveX/rxjs/

See also http://reactivex.io/rxjs/



来源:https://stackoverflow.com/questions/38555727/rxjs-subject-next-or-onnext

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