I did a sample project here, <https://github.com/s...
# rx
s
I did a sample project here, https://github.com/sanogueralorenzo/TestConcatIssue/blob/master/app/src/main/java/com/sanogueralorenzo/testconcatissue/MainActivity.kt even if you use Single.just for the first one you are still able to reproduce the issue sometimes opening the app in airplane mode
m
it’s a race condition, the cache and the remote observable will run concurrently, and the
concat
will enforce the order of emissions, but if there’s an error the single will be immediately terminated
s
but under normal circumstances (no internet connection and pressing a button that fires the
concat
) it will respect the order properly and give back the first and an exception in the second one
why on app open firing it straight away the throwable of the second will eat up the chain, avoiding the cache to be delivered at least?
m
error is not an emission, it doesn’t have to respect the order
like I’ve said your case is a race condition, it’s nondeterministic
add
.onErrorReturnItem("error")
to your
service.test()
call and see how it behaves then
s
sure in that case it will work
but I want to deliver the value of the first single in the concat and then receive the second value (or error) of the second
Concat waits to subscribe to each additional Observable that you pass to it until the previous Observable completes.
this is the key, how can I be getting an error of the second one (even if its not an item) if the first hasn't completed yet
m
In that case you can wrap the second observable in
defer(...)