Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subject.onNext not a function? #1057

Closed
thunderkid opened this issue Dec 14, 2015 · 13 comments
Closed

Subject.onNext not a function? #1057

thunderkid opened this issue Dec 14, 2015 · 13 comments

Comments

@thunderkid
Copy link

I'm trying to get Rx Subjects to work following the RxJs docs. I'm using:

    import * as Rx from 'rxjs';
    var subject = new Rx.Subject();

    var subscription = subject.subscribe(
        function (x) {
            console.log('Next: ' + x);
        },
        function (err) {
            console.log('Error: ' + err);
        },
        function () {
            console.log('Completed');
        });

    subject.onNext(42);

But typescript tells me onNext is not a function, and if I force it with subject:any, the browser also tells me subject.onNext is not a function. Has the syntax changed?

@benlesh
Copy link
Member

benlesh commented Dec 14, 2015

Due to changes to accommodate the ES7 Observable spec, the API has changed for observables:

  • onNext -> next
  • onError -> error
  • onCompleted -> complete

I apologize for any confusion. We're working on a migration strategy (probably documentation) to land during the early stages of beta.

@benlesh
Copy link
Member

benlesh commented Dec 14, 2015

@thunderkid I'm going to close this one for now, as it's not a bug, and I hope that my previous comment addresses your concerns.

@benlesh benlesh closed this as completed Dec 14, 2015
@thunderkid
Copy link
Author

Yes, that fixed it. Thanks. (btw I also noticed bufferWithTime doesn't seem to be there. I'm assuming it's been replaced with bufferTime.)

@benlesh
Copy link
Member

benlesh commented Dec 15, 2015

@thunderkid ... made this today... just for you: https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md

;)

It's a first go, so I expect it will be improved over the next month or so.

@thunderkid
Copy link
Author

Brilliant, thanks. That'll remove a bit of guesswork. What's the eta of the 5.0 stable release?

@dholth
Copy link

dholth commented Sep 24, 2016

I didn't realize https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/subjects/subject.md was a different thing than this one, the former has better Google-Fu.

@KunmyonChoi
Copy link

Do you guys have a plan to give a hint on this document?
https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observer.md

@kwonoj
Copy link
Member

kwonoj commented Nov 23, 2016

@KunmyonChoi it already does. https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#observer-interface-changes-also-subjects . Please note given repo is for RxJS v4, does not contain v5 related changes.

kentoj added a commit to kentoj/rx-book that referenced this issue Nov 23, 2016
Update file to reflect ES7 spec.

https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md

This started changing almost a year ago:
ReactiveX/rxjs#1057
@ORESoftware
Copy link

oh shit I thought it was completed instead of complete, d'oh!

@ORESoftware
Copy link

ORESoftware commented Dec 30, 2016

honestly, I think it would just be better to alias all of them with the old method names, dunno though

@clembu
Copy link

clembu commented Dec 30, 2016

@ORESoftware that would really confuse newcomers. Starting working with a library that's a rewrite of an old one means not dealing with the old one at all. It's a complete rewrite, meaning it's not the same thing, meaning don't get their APIs mingled.
You should never take your knowledge for granted when you change major versions of a dependency.

@ORESoftware
Copy link

ORESoftware commented Dec 30, 2016

@FacelessPanda I am not a huge fan of aliasing, for many reasons, but in this case these methods will never change purpose, so onNext and next should do the same thing, it would be hugely convenient to just make onNext an alias of next, etc.

I don't see how it would be confusing to newcomers. All the documentation would point to the new methods, without any mention of the old. If someone forgets somewhere deep in a codebase to change onNext to next, then it will be simply convenient.

The change from onNext to next is not about breaking changes, it's about conforming to the ES7 spec, so it's really just not necessary to creating breaking changes when you're just renaming things. This is a case where aliasing would actually be just straight up a good thing.

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants