VictorAlbertos / RxActivityResult

A reactive-tiny-badass-vindictive library to break with the OnActivityResult implementation as it breaks the observable chain.
Apache License 2.0
593 stars 72 forks source link

No result when starting 2 activities at the same time #15

Closed riwnodennyk closed 8 years ago

riwnodennyk commented 8 years ago

Failing test attached to https://github.com/VictorAlbertos/RxActivityResult/pull/14

VictorAlbertos commented 8 years ago

Thanks for the feedback. It's really nice having a failing test to start working from it.

I'll check out it as soon as possible.

VictorAlbertos commented 8 years ago

Take a look at the test. Now it's passing.

You need to chain the second call, as follows:

        startTwoForResult.setOnClickListener(v ->
            RxActivityResult.on(this)
                .startIntent(new Intent(this, FirstActivity.class))
                .flatMap(result -> {
                    result.targetUI()
                        .firstResult.setText(result.data().getStringExtra(FirstActivity.EXTRA));
                    return RxActivityResult.on(this)
                        .startIntent(new Intent(this, SecondActivity.class));
                })
                .subscribe(result -> {
                    result.targetUI()
                        .secondResult.setText(result.data().getStringExtra(SecondActivity.EXTRA));
                })
        );

And use result.targetUI(), don't call directly the view reference.