something like this? ``` fun isReadyToGo( logi...
# rx
a
something like this?
Copy code
fun isReadyToGo(
    loginAnonymously: Single<TokenData>,
    saveTokenData: (TokenData) -> Completable,
    isLoggedIn: Single<Boolean>
): Completable {
    return isLoggedIn
        .filter { !it }
        .flatMapSingleElement { loginAnonymously }
        .flatMapCompletable(saveTokenData)
}
not sure if it's not harder to understand though 😛
u
@arekolek, would you mind to explain what happens here?
a
filter
converts
Single
to
Maybe
,
flatMapSingleElement
applies
loginAnonymously
only if that
Maybe
emits an item,
flatMapCompletable
executes
Completable
if
Maybe
emits a
TokenData
👍 2
u
@arekolek, thanks a lot!
I guess
Maybe
is what introduces if/else flow inside reactive flow. It seems so.
l
impressive but not as readable as the initial attempt