-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ajax() returns Observable<{}> instead of Observable<AjaxResponse> #1783
Comments
Seems it makes sense. Let me look bit more and create PR if necessary. |
cc/ @david-driscoll |
I've looked this into bit more to see if it's possible to get rid of generics for ajax creation method, found it's bit tricky.
: Main reason for this is While it's expected to allow generics to AjaxObservable I'm also feeling type definitions can be improved bit better to work with |
Ah but here's the thing -- ajax, which is to say AjaxObservable.create -- isn't written as a generic function. That's why it's so weird that you can even give it a type. I think what's happening is that TypeScript "needs" a type for that AjaxObservable constructor, and so it lets you add one farther up the stack. Which sure sounds like a bug in TypeScript, but that's a different issue for a different rep. On the larger subject, my two cents is this: let ajax continue to return the full AjaxResponse, just like in jQuery. It shouldn't be a generic. If you want to access a REST JSON response as a type, you don't need to resort to resultSelector. You can just do: const source = Observable.ajax({ method:"GET", url: "myurl" }).map(ajaxResponse => ajaxResponse.response as TheTypeOfTheRestResponse); Ditto if you just want part of the response: const source = Observable.ajax({ method:"GET", url: "myurl" }).map(ajaxResponse => ajaxResponse.response["foo"]); Both are simpler and clearer (and more Rx-y) than the equivalent resultSelector code, no? tl;dr: let ajax be ajax, death to resultSelector |
I'm also leaning towards to drop off resultSelector, just unsure if there's solid usecases for those. (But as @billba mentioned, most cases |
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
I've filed PR #1813 to leverage as discussion point. Basically PR drops resultSelector and ensure type delivered to subscription, encourage to use map where selection needed. |
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
closes ReactiveX#1783 BREAKING CHANGE: ajax.*() method no longer support resultSelector, encourage to use `map` instead
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. |
RxJS version: 5.0.0-beta.9
Code to reproduce:
Expected behavior:
Mouse over source to see that it's type Observable<AjaxResponse>
Actual behavior:
It's type Observable<{}>.
Additional information:
What might be going on is that AjaxObservable<T>.create has
and I think it should be:
As a workaround I was able to do:
... but ajax shouldn't really take a type at all and I'm not sure why it even can.
The text was updated successfully, but these errors were encountered: