Skip to content

2.x - CombineLatestDelayError throwing error before subscribing other observables #5558

@saiimons

Description

@saiimons

I am working on a piece of code where I basically have a cached value, which I want to combine with other data and update from the network.

My thought was using combineLatestDelayError and magic would happen! Except when the network is down... Even though I have valid values in both my observables I only end up getting the error.

I narrowed it down to a simple test case:

    @Test
    public void combineLatestDelayErrorFailure() {
        final int result = Observable.combineLatestDelayError(
                Arrays.asList(
                        Observable.just(41).concatWith(Observable.error(new Exception("Failure"))),
                        Observable.just(1).delay(1, TimeUnit.SECONDS)
                ),
                ints -> ((int) ints[0]) + ((int) ints[1])
        ).blockingFirst();
        assertThat(result).isEqualTo(42);
    }

It always throws the Exception.

There is one point in the documentation about the calls being synchronous, though it is not clear to me how I could make changes to my observables to avoid that situation 😿

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions