Skip to content

Conversation

@thomasnield
Copy link
Collaborator

I have added a large number of extension function operators targeting Observable and Flowable types emitting Single<T>, Maybe<T>, and Completable emissions.

@JakeWharton and @stepango, please let me know what you think of these.

Copy link
Collaborator

@stepango stepango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me.

@thomasnield
Copy link
Collaborator Author

thomasnield commented Mar 17, 2017

I am debating removing some of these operators that require a conversion to an Observable to work with an Observable operator. mergeAllMaybes() is a definite since there is a flatMapMaybe(). But concatAllMaybes() might be pushing out of scope since there is no concatMapMaybe(). This also applies to Single and Completable.

/**
 * Concatenates the emissions of an Flowable<Maybe<T>>.
 */
fun <T : Any> Observable<Maybe<T>>.concatAllMaybes() = concatMap { it.toObservable() }

/**
 * Concatenates the emissions of an Flowable<Maybe<T>>.
 */
fun <T : Any> Flowable<Maybe<T>>.concatAllMaybes() = concatMap { it.toFlowable() }

/**
 * Emits the latest `Maybe<T>` emitted through an `Flowable<Maybe<T>>`.
 */
fun <T : Any> Observable<Maybe<T>>.switchLatestMaybe() = switchMap { it.toObservable() }

/**
 * Emits the latest `Maybe<T>` emitted through an `Flowable<Maybe<T>>`.
 */
fun <T : Any> Flowable<Maybe<T>>.switchLatestMaybe() = switchMap { it.toFlowable() }

…be>` and Flowable counterparts, out of scope
@thomasnield
Copy link
Collaborator Author

Decided to rid those operators. You can easily do a toObservable() conversion within a map() before a concatAll() or switchLatest().

@thomasnield thomasnield merged commit 94ffb4f into 2.x Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants