Skip to content

Commit

Permalink
Support for resources list (#100)
Browse files Browse the repository at this point in the history
* Separate functionalities for retrieving collection resources

* Chapter and chunk titles

* Revert "Chapter and chunk titles"

This reverts commit 799b208.

* Revert "Separate functionalities for retrieving collection resources"

This reverts commit bc7bc96.

* Create RxUtils.kt

* Add kdoc to RxUtils.mapNotNull
  • Loading branch information
KJoslyn authored and jsarabia committed Jun 3, 2019
1 parent 877d2fd commit fcd8ca9
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.wycliffeassociates.otter.common.utils

import io.reactivex.Observable

/**
* Apply the given function as with `map()`, but remove any resulting nulls from the
* observable stream.
*
* This is how `observable.map(f).filter { it != null }` should behave, but it keeps
* nulls from ever appearing in an Observable, which would cause a crash in that
* two-step map/filter example.
*/
fun <T, R:Any> Observable<T>.mapNotNull(f: (T) -> R?): Observable<R> =
concatMapIterable { listOfNotNull(f(it)) }

0 comments on commit fcd8ca9

Please sign in to comment.