-
Notifications
You must be signed in to change notification settings - Fork 3k
Incorrect types with switch
?
#2493
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
Comments
I'm not really 100% sure what the underlying goal is, however the switch is in the wrong location. And has almost no meaning (zip, is not function allTogetherNow(): Observable<Payload[]> {
// Get an Observable of a list.
const numsObs = foo();
// Map every item in the Observable list to a new Observable based on
// the returns of the other two functions.
return numsObs.map(nums => {
// For every number in the list:
return Observable.forkJoin(...nums.map(num => {
// Return that number as an Observable.
const numObs = Observable.of(num);
// Then compute the other two Observables.
const strObs = bar(num);
const valObs = baz(num);
// Zip all three together into the Payload object.
return Observable.zip(
numObs, strObs, valObs,
(myNumber, myString, myObject): Payload =>
({ myNumber, myString, myObject })
// And then flatten to get the latest result.
);
}));
}).switch();
} I've made a jsbin with those changes here: http://jsbin.com/teqequsafe/1/edit?js,console,output The big problem comes in with the array map in the middle, which makes this behavior look non-obvious (I've been bitten by it myself). The |
Thanks for the clarification -- your code does exactly what I want 😄 Basically, make a request that returns My understanding of All that being said, I still believe the types are wrong. Why is my editor telling me that the return type of |
As for the types remove the explicit type on |
Sure, I guess I'm just surprised that the types didn't show the issue with what I had -- that's how I got my initial "solution," fumbling around with the operators until I got the return type I wanted. If this doesn't seem like a problem (at least with the types), feel free to close this issue. I'm perfectly happy with your solution. |
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how` hot and cold observables are typed. A few compiler errors were fixed ddue to this change fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how hot and cold observables are typed. A few compiler errors were fixed due to this change. fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how hot and cold observables are typed. A few compiler errors were fixed due to this change. fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how hot and cold observables are typed. A few compiler errors were fixed due to this change. fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how hot and cold observables are typed. A few compiler errors were fixed due to this change. fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll. Also made a few improvements to how hot and cold observables are typed. A few compiler errors were fixed due to this change. fixes ReactiveX#2658 ReactiveX#2493 ReactiveX#2551
Closing via #2690. |
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. |
Uh oh!
There was an error while loading. Please reload this page.
RxJS version:
5.2.0
Code to reproduce:
Expected behavior:
Logs a list of
Payload
objects. Objects should not be instances of Observable.Actual behavior:
Instead of
Payload
Objects in the subscribe function, I'm getting a list of Observables.Here's the actual output I got:
Additional information:
This code is inspired by an Angular service I was working on. You can think of
foo
as getting a list of IDs from the backend, andbar
andbaz
being other backend service calls that take IDs.I don't know if
switch
is causing the bug, so the title of this issue may need to be updated.The text was updated successfully, but these errors were encountered: