Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private inline fun <reified R : Any> Flux<*>.ofType(): Flux<R> = ofType(R::class
* @return a Flux that emits `Some.value` of those items emitted by the source Flux that are `Some`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Flux<Optional<T>>.filterSome(): Flux<T> = ofType<Some<T>>().map { it.value }
fun <T : Any> Flux<out Optional<T>>.filterSome(): Flux<T> = ofType<Some<T>>().map { it.value }

/**
* Filters items emitted by a Flux by only emitting those that are `None`.
Expand All @@ -25,4 +25,4 @@ fun <T : Any> Flux<Optional<T>>.filterSome(): Flux<T> = ofType<Some<T>>().map {
* @return a Flux that emits `Unit` for each item emitted by the source Flux that is `None`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Flux<Optional<T>>.filterNone(): Flux<Unit> = ofType<None>().map { Unit }
fun <T : Any> Flux<out Optional<T>>.filterNone(): Flux<Unit> = ofType<None>().map { Unit }
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gojuno.koptional.reactor

import com.gojuno.koptional.None
import com.gojuno.koptional.Optional
import com.gojuno.koptional.Some
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.context
Expand All @@ -10,7 +11,7 @@ import reactor.test.StepVerifier

class ReactorExtensionsSpec : Spek({

val stream by memoized {
val stream: Flux<out Optional<String>> by memoized {
Flux.just(Some("a"), None, Some("b"), Some("c"), None)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private inline fun <reified R : Any> Single<*>.ofType(): Maybe<R> = filter { it
* @return an Observable that emits `Some.value` of those items emitted by the source ObservableSource that are `Some`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Observable<Optional<T>>.filterSome(): Observable<T> = ofType<Some<T>>().map { it.value }
fun <T : Any> Observable<out Optional<T>>.filterSome(): Observable<T> = ofType<Some<T>>().map { it.value }

/**
* Filters items emitted by a Publisher by only emitting those that are `Some`.
Expand All @@ -39,7 +39,7 @@ fun <T : Any> Observable<Optional<T>>.filterSome(): Observable<T> = ofType<Some<
* @return an Flowable that emits `Some.value` of those items emitted by the source Publisher that are `Some`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Flowable<Optional<T>>.filterSome(): Flowable<T> = ofType<Some<T>>().map { it.value }
fun <T : Any> Flowable<out Optional<T>>.filterSome(): Flowable<T> = ofType<Some<T>>().map { it.value }

/**
* Filters items emitted by an MaybeSource by only emitting those that are `Some`.
Expand All @@ -53,7 +53,7 @@ fun <T : Any> Flowable<Optional<T>>.filterSome(): Flowable<T> = ofType<Some<T>>(
* @return an Maybe that emits `Some.value` of those items emitted by the source MaybeSource that are `Some`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Maybe<Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map { it.value }
fun <T : Any> Maybe<out Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map { it.value }

/**
* Filters items emitted by an SingleSource by only emitting those that are `Some`.
Expand All @@ -67,7 +67,7 @@ fun <T : Any> Maybe<Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map
* @return an Maybe that emits `Some.value` of those items emitted by the source SingleSource that are `Some`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Single<Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map { it.value }
fun <T : Any> Single<out Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map { it.value }

/**
* Filters items emitted by an ObservableSource by only emitting those that are `None`.
Expand All @@ -81,7 +81,7 @@ fun <T : Any> Single<Optional<T>>.filterSome(): Maybe<T> = ofType<Some<T>>().map
* @return an Observable that emits `Unit` for each item emitted by the source ObservableSource that is `None`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Observable<Optional<T>>.filterNone(): Observable<Unit> = ofType<None>().map { Unit }
fun <T : Any> Observable<out Optional<T>>.filterNone(): Observable<Unit> = ofType<None>().map { Unit }

/**
* Filters items emitted by an Publisher by only emitting those that are `None`.
Expand All @@ -95,7 +95,7 @@ fun <T : Any> Observable<Optional<T>>.filterNone(): Observable<Unit> = ofType<No
* @return an Flowable that emits `Unit` for each item emitted by the source Publisher that is `None`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Flowable<Optional<T>>.filterNone(): Flowable<Unit> = ofType<None>().map { Unit }
fun <T : Any> Flowable<out Optional<T>>.filterNone(): Flowable<Unit> = ofType<None>().map { Unit }

/**
* Filters items emitted by an MaybeSource by only emitting those that are `None`.
Expand All @@ -109,7 +109,7 @@ fun <T : Any> Flowable<Optional<T>>.filterNone(): Flowable<Unit> = ofType<None>(
* @return an Maybe that emits `Unit` for each item emitted by the source MaybeSource that is `None`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Maybe<Optional<T>>.filterNone(): Maybe<Unit> = ofType<None>().map { Unit }
fun <T : Any> Maybe<out Optional<T>>.filterNone(): Maybe<Unit> = ofType<None>().map { Unit }

/**
* Filters items emitted by an SingleSource by only emitting those that are `None`.
Expand All @@ -123,4 +123,4 @@ fun <T : Any> Maybe<Optional<T>>.filterNone(): Maybe<Unit> = ofType<None>().map
* @return an Maybe that emits `Unit` for each item emitted by the source SingleSource that is `None`.
* @see <a href="http://reactivex.io/documentation/operators/filter.html">ReactiveX operators documentation: Filter</a>
*/
fun <T : Any> Single<Optional<T>>.filterNone(): Maybe<Unit> = ofType<None>().map { Unit }
fun <T : Any> Single<out Optional<T>>.filterNone(): Maybe<Unit> = ofType<None>().map { Unit }
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RxJava2ExtensionsSpec : Spek({

context("Observable") {

val stream by memoized {
val stream: Observable<out Optional<String>> by memoized {
Observable.just(Some("a"), None, Some("b"), Some("c"), None)
}

Expand Down Expand Up @@ -70,7 +70,7 @@ class RxJava2ExtensionsSpec : Spek({

context("Flowable") {

val stream by memoized {
val stream: Flowable<out Optional<String>> by memoized {
Flowable.just(Some("a"), None, Some("b"), Some("c"), None)
}

Expand Down Expand Up @@ -124,8 +124,8 @@ class RxJava2ExtensionsSpec : Spek({
context("Maybe") {

context("Stream with Some") {
val stream by memoized {
Maybe.just(Some("a") as Optional<String>)
val stream: Maybe<out Optional<String>> by memoized {
Maybe.just(Some("a"))
}

context("filterSome") {
Expand Down Expand Up @@ -177,8 +177,8 @@ class RxJava2ExtensionsSpec : Spek({
}

context("Stream with None") {
val stream by memoized {
Maybe.just(None as Optional<String>)
val stream: Maybe<out Optional<String>> by memoized {
Maybe.just(None)
}

context("filterSome") {
Expand Down Expand Up @@ -232,8 +232,8 @@ class RxJava2ExtensionsSpec : Spek({
context("Single") {

context("Stream with Some") {
val stream by memoized {
Single.just(Some("a") as Optional<String>)
val stream: Single<out Optional<String>> by memoized {
Single.just(Some("a"))
}

context("filterSome") {
Expand Down Expand Up @@ -285,8 +285,8 @@ class RxJava2ExtensionsSpec : Spek({
}

context("Stream with None") {
val stream by memoized {
Single.just(None as Optional<String>)
val stream: Single<out Optional<String>> by memoized {
Single.just(None)
}

context("filterSome") {
Expand Down