Skip to content

Maybe concat with firstElement still call second Maybe although the first emit value #5100

Closed
@ekosuhariyadi

Description

@ekosuhariyadi

Hi, I'm relatively new to RxJava.

I tried RxJava 2.0.6 (previously 2.0.5) to check if it still produces the same result.

Here my code (still using Java 6)

Maybe<String> m1 = Maybe.create(new MaybeOnSubscribe<String>() {

    @Override public void subscribe(MaybeEmitter<String> e) throws Exception {
        System.out.println("m1 called");
        e.onSuccess("m1");
    }
});
Maybe<String> m2 = Maybe.create(new MaybeOnSubscribe<String>() {

    @Override public void subscribe(MaybeEmitter<String> e) throws Exception {
        System.out.println("m2 called");
        e.onSuccess("m2");
    }
});
Disposable subscribe = Maybe.concat(m1, m2)
        .firstElement()
        .subscribe(new Consumer<String>() {

            @Override public void accept(String t) throws Exception {
                System.out.println(t);
            }
        });

the output :
m1 called
m1
m2 called

Is it correct or not? Because while using Observable, the second Observable is not called when the first one already emit value

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions