Last active
August 29, 2015 14:10
-
-
Save sdesai/e22a6376fc0769337b84 to your computer and use it in GitHub Desktop.
Nested switchMap Issue?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Observable = Rx.Observable; | |
// Nested SwitchLatest/SwitchMap BROKEN? | |
// Expecting: "A", "B" (with synchronous scheduler/execution) | |
// Observed: "B" | |
Observable.of( | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}), | |
Observable.of('B') | |
). | |
switchLatest(). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// Expecting: "A", "B" (with synchronous scheduler/execution) | |
// Observed: "B" | |
Observable.of( | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}), | |
Observable.of('B').switchMap(function(o) { | |
return Observable.of(o); | |
}) | |
). | |
switchLatest(). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// Expecting: "A", "B", "C" (with synchronous scheduler/execution) | |
// Observed: "C" | |
Observable.of( | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}), | |
Observable.of('B').switchMap(function(o) { | |
return Observable.of(o); | |
}), | |
Observable.of('C').switchMap(function(o) { | |
return Observable.of(o); | |
}) | |
). | |
switchLatest(). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// 'WORKING' VARIANTS | |
// Expecting: "B", "A" | |
// Observed: "B", "A" | |
Observable.of( | |
Observable.of('B'), | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}) | |
). | |
switchLatest(). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// Expecting: "A" | |
// Observed: "A" | |
Observable.of( | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}) | |
). | |
switchLatest(). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// Expecting: "A" | |
// Observed: "A" | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}). | |
forEach(function(o){ | |
console.log(o); | |
}); | |
// Expecting: Two Observables On Nexted | |
// Observed: Two Observables On Nexted | |
Observable.of( | |
Observable.of('A').switchMap(function(o) { | |
return Observable.of(o); | |
}), | |
Observable.of('B').switchMap(function(o) { | |
return Observable.of(o); | |
}) | |
). | |
// switchLatest(). removed | |
forEach(function(o){ | |
console.log(o); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment