.additions() = JavaFxObservable.additionsOf(this)
/**
* Creates an observable that emits all updated items from an ObservableList.
* If you declare an ObservableList that listens to one or more properties of each element,
* you can emit the changed items every time these properties are modified
* ObservableList sourceList = FXCollections.observableArrayList(user -> new javafx.beans.Observable[]{user.age} );
* @return An Observable emitting items updated in the ObservableList
*/
fun ObservableList.updates() = JavaFxObservable.updatesOf(this)
/**
* Emits all added, removed, and updated items from an ObservableList
* @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableList.changes() = JavaFxObservable.changesOf(this)
/**
* Emits distinctly added and removed items from an ObservableList.
* If dupe items with identical hashcode/equals evaluations are added to an ObservableList, only the first one will fire an ADDED item.
* When the last dupe is removed, only then will it fire a REMOVED item.
* @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableList.distinctChanges() = JavaFxObservable.distinctChangesOf(this)
/**
* Emits distinctly added and removed items item from an ObservableList.
* If dupe mapped R items with identical hashcode/equals evaluations are added to an ObservableList, only the first one will fire an ADDED T item.
* When the last dupe is removed, only then will it fire a REMOVED T item.
* @return An Observable emitting changed mapped items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableList.distinctChanges(mapper: ((T) -> R)) = JavaFxObservable.distinctChangesOf(this,mapper)
/**
* Emits distinctly added and removed mappings to each R item from an ObservableList.
* If dupe mapped R items with identical hashcode/equals evaluations are added to an ObservableList, only the first one will fire an ADDED R item.
* When the last dupe is removed, only then will it fire a REMOVED R item.
* @return An Observable emitting changed mapped items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableList.distinctMappingChanges(mapper: ((T) -> R)) = JavaFxObservable.distinctMappingsOf(this,mapper)
/**
* Creates an observable that emits an ObservableMap every time it is modified
* @return An Observable emitting the ObservableMap each time it changes
*/
fun ObservableMap.onChangedObservable() = JavaFxObservable.emitOnChanged(this)
/**
* Creates an observable that emits all removal items from an ObservableMap
* @return An Observable emitting items removed from the ObservableMap
*/
fun ObservableMap.removals() = JavaFxObservable.removalsOf(this)
/**
* Creates an observable that emits all additions to an ObservableMap
* @return An Observable emitting items added to the ObservableMap
*/
fun ObservableMap.additions() = JavaFxObservable.additionsOf(this)
/**
* Emits all added, removed, and updated items from an ObservableMap
* @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableMap.changes() = JavaFxObservable.changesOf(this)
/**
* Creates an observable that emits an ObservableSet every time it is modified
* @return An Observable emitting the ObservableSet each time it changes
*/
fun ObservableSet.onChangedObservable() = JavaFxObservable.emitOnChanged(this)
/**
* Creates an observable that emits all removal items from an ObservableSet
* @return An Observable emitting items removed from the ObservableSet
*/
fun ObservableSet.removals() = JavaFxObservable.removalsOf(this)
/**
* Creates an observable that emits all additions to an ObservableSet
* @return An Observable emitting items added to the ObservableSet
*/
fun ObservableSet.additions() = JavaFxObservable.additionsOf(this)
/**
* Emits all added, removed, and updated items from an ObservableSet
* @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags
*/
fun ObservableSet>.changes() = JavaFxObservable.changesOf(this)
/**
* Emits the response `T` for a given `Dialog`. If no response is provided the Maybe will be empty.
*/
fun Dialog.toMaybe() = JavaFxObservable.fromDialog(this)!!
================================================
FILE: src/main/kotlin/com/github/thomasnield/rxkotlinfx/Operators.kt
================================================
package com.github.thomasnield.rxkotlinfx
import io.reactivex.*
import io.reactivex.rxjavafx.schedulers.JavaFxScheduler
import io.reactivex.rxjavafx.transformers.FxFlowableTransformers
import io.reactivex.rxjavafx.transformers.FxObservableTransformers
import javafx.application.Platform
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Observable#observeOn(JavaFxScheduler.platform())
*/
fun Observable.observeOnFx() = observeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Flowable#observeOn(JavaFxScheduler.platform())
*/
fun Flowable.observeOnFx() = observeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Single#observeOn(JavaFxScheduler.platform())
*/
fun Single.observeOnFx() = observeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Maybe#observeOn(JavaFxScheduler.platform())
*/
fun Maybe.observeOnFx() = observeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Completable#observeOn(JavaFxScheduler.platform())
*/
fun Completable.observeOnFx() = observeOn(JavaFxScheduler.platform())
/**
* Instructs the source Observable to emit items on the JavaFX Thread.
* This is the same as calling Observable#subscribeOn(JavaFxScheduler.platform())
*/
fun Observable.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())
/**
* Instructs the source Flowable to emit items on the JavaFX Thread.
* This is the same as calling Flowable#subscribeOn(JavaFxScheduler.platform())
*/
fun Flowable.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Single#subscribeOnFx(JavaFxScheduler.platform())
*/
fun Single.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Maybe#subscribeOnFx(JavaFxScheduler.platform())
*/
fun Maybe.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())
/**
* Observes the emissions on the JavaFX Thread.
* This is the same as calling Completable#subscribeOnFx(JavaFxScheduler.platform())
*/
fun Completable.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())
/**
* Performs the provided onNext action on the FX thread
*/
inline fun Observable.doOnNextFx(crossinline onNext: (T) -> Unit): Observable = doOnNext {
Platform.runLater { onNext.invoke(it) }
}
/**
* Performs the provided onNext action on the FX thread
*/
inline fun Flowable.doOnNextFx(crossinline onNext: (T) -> Unit): Flowable = doOnNext {
Platform.runLater { onNext.invoke(it) }
}
/**
* Performs the provided onError action on the FX thread
*/
inline fun Observable.doOnErrorFx(crossinline onError: (Throwable) -> Unit): Observable = doOnError {
Platform.runLater { onError.invoke(it) }
}
/**
* Performs the provided onError action on the FX thread
*/
inline fun Flowable.doOnErrorFx(crossinline onError: (Throwable) -> Unit): Flowable = doOnError {
Platform.runLater { onError.invoke(it) }
}
/**
* Performs the provided onComplete action on the FX thread
*/
inline fun Observable.doOnCompleteFx(crossinline onComplete: () -> Unit): Observable = doOnComplete {
Platform.runLater { onComplete.invoke() }
}
/**
* Performs the provided onComplete action on the FX thread
*/
inline fun Flowable.doOnCompleteFx(crossinline onComplete: () -> Unit): Flowable = doOnComplete {
Platform.runLater { onComplete.invoke() }
}
/**
* Performs the provided onSubscribe action on the FX thread
*/
inline fun Observable.doOnSubscribeFx(crossinline onSubscribe: () -> Unit): Observable = doOnSubscribe {
Platform.runLater { onSubscribe.invoke() }
}
/**
* Performs the provided onSubscribe action on the FX thread
*/
inline fun Flowable.doOnSubscribeFx(crossinline onSubscribe: () -> Unit): Flowable = doOnSubscribe {
Platform.runLater { onSubscribe.invoke() }
}
/**
* Performs the provided onTerminate action on the FX thread
*/
inline fun Observable.doOnTerminateFx(crossinline onTerminate: () -> Unit): Observable = doOnTerminate {
Platform.runLater { onTerminate.invoke() }
}
/**
* Performs the provided onTerminate action on the FX thread
*/
inline fun Flowable.doOnTerminateFx(crossinline onTerminate: () -> Unit): Flowable = doOnTerminate {
Platform.runLater { onTerminate.invoke() }
}
/**
* Performs the provided onDispose action on the FX thread
*/
inline fun Observable.doOnDisposeFx(crossinline onDispose: () -> Unit): Observable = this.doOnDispose {
Platform.runLater { onDispose.invoke() }
}
/**
* Performs the provided onDispose action on the FX thread
*/
inline fun Flowable.doOnCancelFx(crossinline onDispose: () -> Unit): Flowable = this.doOnCancel {
Platform.runLater { onDispose.invoke() }
}
/**
* Executes side effect with the accumulating count of emissions for each onNext() call
*/
fun Observable.doOnNextCount(onNext: (Int) -> Unit): Observable =
compose(FxObservableTransformers.doOnNextCount(onNext))
/**
* Executes side effect with the accumulating count of emissions for each onNext() call
*/
fun Flowable.doOnNextCount(onNext: (Int) -> Unit): Flowable =
compose(FxFlowableTransformers.doOnNextCount(onNext))
/**
* Executes side effect with the total count of emissions for the onComplete() call
*/
fun Observable.doOnCompleteCount(onComplete: (Int) -> Unit): Observable =
compose(FxObservableTransformers.doOnCompleteCount(onComplete))
/**
* Executes side effect with the total count of emissions for the onComplete() call
*/
fun Flowable.doOnCompleteCount(onComplete: (Int) -> Unit): Flowable =
compose(FxFlowableTransformers.doOnCompleteCount(onComplete))
/**
* Executes side effect with the total count of emissions for an onError() call
*/
fun Observable.doOnErrorCount(onError: (Int) -> Unit): Observable =
compose(FxObservableTransformers.doOnErrorCount(onError))
/**
* Executes side effect with the total count of emissions for an onError() call
*/
fun Flowable.doOnErrorCount(onError: (Int) -> Unit): Flowable =
compose(FxFlowableTransformers.doOnErrorCount(onError))
/**
* Executes side effect on FX thread with the accumulating count of emissions for each onNext() call
*/
fun Observable.doOnNextCountFx(onNext: (Int) -> Unit) = doOnNextCount { Platform.runLater { onNext.invoke(it) } }
/**
* Executes side effect on FX thread with the accumulating count of emissions for each onNext() call
*/
fun Flowable.doOnNextCountFx(onNext: (Int) -> Unit) = doOnNextCount { Platform.runLater { onNext.invoke(it) } }
/**
* Executes side effect on FX thread with the total count of emissions for the onComplete() call
*/
fun Observable.doOnCompleteCountFx(onComplete: (Int) -> Unit) = doOnCompleteCount { Platform.runLater { onComplete.invoke(it) } }
/**
* Executes side effect on FX thread with the total count of emissions for the onComplete() call
*/
fun Flowable.doOnCompleteCountFx(onComplete: (Int) -> Unit) = doOnCompleteCount { Platform.runLater { onComplete.invoke(it) } }
/**
* Executes side effect on FX thread with the total count of emissions for the onError() call
*/
fun Observable