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

Observer.create, Observable.from and so on not working with Typescript #2429

Closed
Deviad opened this issue Mar 1, 2017 · 6 comments
Closed

Comments

@Deviad
Copy link

Deviad commented Mar 1, 2017

I am a novice in RxJS, but I think this might be a consequence of #2369

Anyways, your help is appreciated, even because I do not know where to look for updated docs or info on this matter.

RxJS version: 5

**Code to reproduce: https://github.com/Deviad/fbmetascraperandcrudapits

Expected behavior: I should be able to use static methods like from, create using Typescript as in plain vanilla JS.

Actual behavior: I cannot use functions like Observer.create (have to use Subscriber.create instead), Observable.from() and others.

Additional information:

@kwonoj
Copy link
Member

kwonoj commented Mar 1, 2017

Observer is not a implementation but only interface, even TypeScript user cannot use Observer.Create() since there isn't those creation method. Basically usecases between TS user and JS user is not different, the only difference is TS user has some more tooling support like intellisense. Codewise both should be identical.

For creation method, Observable<T> has static creation method Observable.create (http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-create), and as commented Observable.from (http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-from) and other variant of creation methods provides way to create other than raw creation method. Though it is not complete, you can refer documentation at http://reactivex.io/rxjs/, and test case serves references usecases as well (https://github.com/ReactiveX/rxjs/tree/master/spec), and if you're familiar with v4 interfaces, migration guide provides difference between breaking version update. (https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md).

@Deviad
Copy link
Author

Deviad commented Mar 1, 2017

@kwonoj
I did not quite understand this part:

Basically usecases between TS user and JS user is not different, the only difference is TS user has some more tooling support like intellisense. Codewise both should be identical.

In fact, in my experience, since JS does not have any kind of control on types, with JS you can still use Rx.Observer.create() hence generating confusion (as you can see here). Somehow the developers should forbid the use of Observer.create() or throw a warning via console.log() that the use of Observer.create() has been deprecated in favor of Subscriber.create() as specified in the reference manual for migration that you kindly attached.

Thank you for your answer.

Cheers,
Davide

@mpodlasin
Copy link
Contributor

mpodlasin commented Mar 1, 2017

I fired up app.js and made request to the endpoint which you created. App crashed, telling me that Rx.Observer is undefined. Which it is, since it is just TS construct, as @kwonoj pointed out.
We can't do anything when app is starting, but that is the nature of JS, not RxJS. Are we missing your point?

@Deviad
Copy link
Author

Deviad commented Mar 1, 2017

@Podlas29, I am sorry, probably I was not clear enough in my previous reply.
My point is that having maximum freedom on plain Javascript so that you can even use Observer.create() without having any warning or error whatsoever generates even more confusion.
I repeat: on vanilla JS Observer.create() still works without any problem.

Since these changes to the library are not enough highlighted, advertised, whatever, until the links to the new version of the website are fixed and the docs updated, as per this bug report, it's inevitable that more people are going to deal with the same problems.

I hope I explained myself better this time.

Thank you.

Cheers,
Davide

@kwonoj
Copy link
Member

kwonoj commented Mar 1, 2017

While I don't get the idea of on vanilla JS Observer.create() still works without any problem. means whole since v5 doesn't have any implementation for this, I believe question itself has been answered to point out starting point. Still documentation issue is being opened and will be tracked to remove further confusions between different versions with breaking changes.

@kwonoj kwonoj closed this as completed Mar 1, 2017
@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

3 participants