[
  {
    "path": ".gitignore",
    "content": ".gradle/\nbuild/\n*.iml\n*.class\n*.prefs\n*.classpath\n.project\n.idea/\ngradle.properties\nsecring.gpg\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n"
  },
  {
    "path": "README.md",
    "content": "\n![](https://camo.githubusercontent.com/78eeb41c5378ae03cf0d23e71c3e0c9e61b0d984/687474703a2f2f692e696d6775722e636f6d2f7837726d586b652e706e67)\n\n# UNSUPPORTED, PLEASE FORK AND SUPPORT\n\n# RxKotlinFX\nKotlin extensions to the [RxJavaFX](https://github.com/ReactiveX/RxJavaFX) library. This framework works especially well with [TornadoFX](https://github.com/edvin/tornadofx). See a fully functional demo [here!](https://github.com/thomasnield/rxkotlinfx-tornadofx-demo)\n\n## Documentation\n[Learning RxJava with JavaFX](https://www.gitbook.com/book/thomasnield/rxjavafx-guide/details)\n\n\n## Binaries\n\nBinaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cio.reactivex.rxjavafx).\n\nExample for Maven:\n\n```xml\n<dependency>\n    <groupId>com.github.thomasnield</groupId>\n    <artifactId>rxkotlinfx</artifactId>\n    <version>x.y.z</version>\n</dependency>\n```\n\nGradle: \n\n```groovy \nrepositories {\n    mavenCentral()\n}\ndependencies {\n    compile 'com.github.thomasnield:rxkotlinfx:x.y.z'\n}\n```\n## Contributing\nFeel free to contribute and help streamline a pragmatic UI stack with Kotlin, RxJava, and JavaFX. Speaking of stacks, this project may be used in conjunction with [TornadoFX](https://github.com/edvin/tornadofx) and [RxKotlin](https://github.com/ReactiveX/RxKotlin). Please make sure no extension naming conventions conflict with these two other libraries :)\n\n## Features\n\nRxKotlinFX is the convergence of interoperability between [RxJava](https://github.com/ReactiveX/RxJava), [JavaFX](http://docs.oracle.com/javase/8/javase-clienttechnologies.htm), and [Kotlin](https://kotlinlang.org/). \n\n![](http://i.imgur.com/Bhh5CX4.png)\n\nRxKotlinFX contains Kotlin extensions to [RxJavaFX](https://github.com/ReactiveX/RxJavaFX) as well as additional `Observable` operators specific to JavaFX. It also is in exporatory stages to add helpful `Node` extension functions that return Observables. This exploration is inspired by the JavaFX/Kotlin interop project [TornadoFX](https://github.com/edvin/tornadofx). Where TornadoFX handles layouts, node extensions, DI, and other JavaFX/Kotlin interoperations, this library will seek to integrate RxJava with JavaFX in the same spirit using Kotlin. The vision is to add useful extensions that put `Observable` streams as properties and functions on JavaFX components, especially where `ObservableValue` properties are not readily available. \n\n### RxJavaFX Extensions\nThe core API implements [RxJavaFX](https://github.com/ReactiveX/RxJavaFX) static factories as extension functions. \n\n|Target Type|Extension Function|Description|\n|---|---|---\n|Observable&lt;T>|toBinding()|Subscribes the `Observable<T>` to a JavaFX `Binding` implementation. Calling `dispose()` will unsubscribe from the `Observable<T>`\n|Observable&lt;T>|toLazyBinding()|Subscribes the `Observable<T>` to a lazy JavaFX `Binding` implementation, delaying subscription until a value is needed. Calling `dispose()` will unsubscribe from the `Observable<T>`\n|Property&lt;T>|bind(observable: Observable&lt;T>)|Binds a `Property<T>` to the emissions of an `Observable<T>`, and returns the `Binding`\n|Binding&lt;T>|addTo(compositeBinding: CompositeBinding)|Adds the `Binding` to a `CompositeBinding`, and returns the `Binding`\n|ObservableValue&lt;T>|toObservable()|Turns a JavaFX `ObservableValue<T>` into an RxJava `Observable<T>` that emits the latest value\n|ObservableValue&lt;T>|toObservableChanges()|Turns a JavaFX `ObservableValue<T>` into an RxJava `Observable<Change<T>>` that emits the old value and new value as a pair\n|Dialog&lt;T>|toObservable&lt;T>|Returns an `Observable<T>` that emits the given result of `Dialog<T>`. Will be empty if no response. \n|Node, Window,  Scene|events(eventType: EventType<T>)| Creates an `Observable` emitting events of the given `EventType`\n|Node, MenuItem, ContextMenu |actionEvents()|Creates an `Observable` that emits an `ActionEvent` every time one occurs\n|ObservableList&lt;T>|onChangedObservable()|Returns an `Observable<ObservableList<T>>` that emits the entire `ObservableList<T>` every time it is modified.\n|ObservableList&lt;T>|additions()|Creates an `Observable<T>` emitting `T` items that were added to the `ObservableList<T>`\n|ObservableList&lt;T>|removals()|Creates an `Observable<T>` emitting `T` items that were removed from the `ObservableList<T>`\n|ObservableList&lt;T>|updates()|Creates an `Observable<T>` emitting `T` items whose specified properties were updated in the `ObservableList<T>`\n|ObservableList&lt;T>|changes()|Creates an `Observable<ListChange<T>>` emitting `ListChange<T>` items, which pairs each item with an `ADDED`, `REMOVED`, or `UPDATED` flag\n|ObservableList&lt;T>|distinctChanges()|Creates an `Observable<ListChange<T>>` emitting *distinct* `ListChange<T>` items. It  will only emit the first `ADDED` item `T` and not emit dupes, and will only emit the `REMOVED` item `T` when no more dupes exist\n|ObservableList&lt;T>|distinctChanges(mapper: (T) -> R)|Creates an `Observable<ListChange<T>>` emitting *distinct* `ListChange<T>` items based off the `mapper`'s definition of a distinct value `R`. It  will only emit the first `ADDED` item `T` and not emit dupes, and will only emit the `REMOVED` item `T` when no more dupes exist\n|ObservableList&lt;T>|distinctMappingChanges(mapper: (T) -> R)|Creates an `Observable<ListChange<R>>` emitting *distinct* `ListChange<R>` mappings based off the `mapper`'s definition of a distinct value `R`. It  will only emit the first `ADDED` item `R` and not emit dupes, and will only emit the `REMOVED` item `R` when no more dupes exist\n\n\n##### Observable of Button ActionEvents\n```kotlin\nval myButton = Button(\"Press Me\")\nval subscription = myButton.actionEvents().subscribe { println(\"Pressed!\") } \n```\n##### Creating a Reactive Binding\n```kotlin\nval myButton = Button(\"Press Me\")\n\nval countBinding = myButton.actionEvents().map { 1 }\n    .scan(0, { x,y -> x + y })\n    .map { it.toString() }\n    .toBinding()\n    \nval myLabel = Label()\nmyLabel.textProperty().bind(countBinding)\n```\n\n##### Observable of ObservableList Events\n```kotlin\nval items = FXCollections.observableArrayList(\"Alpha\", \"Beta\", \"Gamma\")\n\nval changes = items.changes()\n\nchanges.filter { it.flag == Flag.ADDED }\n        .map { it.value }\n        .subscribe { println(\"ADDED $it\") }\n\nitems.add(\"Delta\")\nitems.add(\"Epsilon\")\n```\n###### OUTPUT\n```\nADDED Delta\nADDED Epsilon\n```\n\n##### Turning an ObservableList into a Hot Concatenation\n\n```kotlin\nval observableList = FXCollections.observableArrayList<String>()\n\nobservableList.onChangedObservable()\n        .flatMap {\n            it.toObservable().map { it.length }\n                    .map { it.toString() }\n                    .reduce { s1,s2 -> s1 + \"|\"  + s2  }\n        }\n        .subscribe { println(it) }\n\nobservableList.setAll(\"Alpha\", \"Beta\", \"Gamma\")\nobservableList.add(\"Delta\")\nobservableList.add(\"Epsilon\")\nobservableList.remove(\"Alpha\")\n\n```\n###### OUTPUT\n```\n5|4|5\n5|4|5|5\n5|4|5|5|7\n4|5|5|7\n```\n\n##### Using a Dialog or Alert\n\n```kotlin\nval dialog = Alert(AlertType.CONFIRMATION, \"Are you sure you want to continue?\")\n\ndialog.toObservable().filter { it == ButtonType.YES }\n\t.subscribe { println(\"You pressed YES\") } \n```\n\n##### Using and Disposing CompositeBinding\n```kotlin\nval binding1: Binding = ...\nval binding2: Binding = ... \n\n//adding one at a time\nval bindings = CompositeBinding()\nval bindings += binding1\nval bindings += binding2\n\n//or all at once\nval bindings = CompositeBinding(binding1,binding2)\n\n//do stuff, then dispose Bindings\nbindings.dispose()\n```\n\n\n### Operators\nRxKotlinFX has a growing list of operators placed as extension functions onto `Observable` that aid interoperability with JavaFX.\n\n|Operator|Description|\n|----|-----|\n|observeOnFx()|Schedules the emissions to be observed on the JavaFX thread\n|subscribeOnFx()|Schedules the source `Observable` to emit items on the JavaFX thread\n|doOnNextFx()|Executes the specified action on the FX thread for each emission\n|doOnErrorFx()|Executes the specified action on the FX thread when an error is emitted\n|doOnCompleteFx()|Executes the specified action on the FX thread when the `Observable` calls `onComplete()`\n|doOnSubscribeFx()|Executes the specified action on the FX thread when the `Observable` is first subscribed\n|doOnTerminateFx()|Executes the specified action on the FX thread when the `Observable` calls `onComplete()` or `onError()`\n|doOnDisposeFx()|Executes the specified action on the FX thread when the `Observable` is unsubscribed\n|doOnNextCount()|Executes the specified action with the cumulative count of emissions for that emission\n|doOnErrorCount()|Executes the specified action with the cumulative count of emissions when an error is emitted\n|doOnCompleteCount()|Executes the specified action with the total emission count when `onComplete()` is called\n|doOnNextCountFx()|Same as `doOnNextCount()` except action is executed on FX thread\n|doOnErrorCountFx()|Same as `doOnErrorCount()` except action is executed on FX thread\n|doOnCompleteCountFx()|Same as `doOnCompleteCount()` except action is executed on FX thread\n\nThe `doOnXXXCount()` operators are especially helpful for providing a status update of how many items have been \"processed\" by an `Observable`. \n\n```kotlin\nval source = Observable.range(1,1000)\nval processedCountLabel = Label()\n\nsource.map { it * 10 }\n     .doOnNextFx { processedCountLabel.text = \"Processed $it items\" }\n     .subsribe { doSomethingWith(it) }\n```\n\n### Control Extensions\nThe rest of the project will likely add convenient extension functions to emit events as `Observable` values, [much like the TornadoFX project has done](https://github.com/edvin/tornadofx/blob/master/src/main/java/tornadofx/Nodes.kt). For example, helpful `Observable` extension functions and properties can be added to `TableView` and `ListView`, such as selection events.\n\n```kotlin\nval tableView: TableView<MyItem> = ...\nval selections: Observable<MyItem> = tableView.itemSelections\nval rowIndexSelections: Observable<Int> = tableView.rowIndexSelections\n```\n\nCheck releases as well the [Nodes code file](https://github.com/thomasnield/RxKotlinFX/blob/master/src/main/kotlin/rx/javafx/kt/Nodes.kt) to see a list of available extensions. Feel free to contribute if you see any missing.\n\n\n## Bugs and Feedback\n\nFor bugs, questions and discussions please use the [Github Issues](https://github.com/thomasnield/RxKotlinFx/issues).\n\n \n## LICENSE\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n<http://www.apache.org/licenses/LICENSE-2.0>\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n"
  },
  {
    "path": "build.gradle",
    "content": "buildscript {\n    ext.kotlin_version = '1.1.60'\n\n    repositories {\n    mavenCentral()\n  }\n  dependencies {\n    classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n  }\n}\n\napply plugin: \"kotlin\"\napply plugin: 'maven'\napply plugin: 'signing'\n\nsourceCompatibility = JavaVersion.VERSION_1_8\ntargetCompatibility = JavaVersion.VERSION_1_8\n\nrepositories {\n  mavenCentral()\n}\n\n\ndependencies {\n    compile \"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version\"\n    compile 'io.reactivex.rxjava2:rxjavafx:2.2.2'\n    testCompile 'junit:junit:4.12'\n}\n\n\ntask javadocJar(type: Jar) {\n    classifier = 'javadoc'\n    from javadoc\n}\n\ntask sourcesJar(type: Jar) {\n    classifier = 'sources'\n    from sourceSets.main.allSource\n}\n\nartifacts {\n    archives javadocJar, sourcesJar\n}\n\nsigning {\n    sign configurations.archives\n}\n\ngroup = \"com.github.thomasnield\"\narchivesBaseName = \"rxkotlinfx\"\nversion = \"2.2.2\"\n\nuploadArchives {\n    repositories {\n        mavenDeployer {\n            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }\n\n            repository(url: \"https://oss.sonatype.org/service/local/staging/deploy/maven2/\") {\n                authentication(userName: ossrhUsername, password: ossrhPassword)\n            }\n\n            snapshotRepository(url: \"https://oss.sonatype.org/content/repositories/snapshots/\") {\n                authentication(userName: ossrhUsername, password: ossrhPassword)\n            }\n\n            pom.project {\n                name 'RxKotlinFX'\n                packaging 'jar'\n                // optionally artifactId can be defined here\n                description 'Interoperability library for RxJava, JavaFX, and Kotlin'\n                url 'https://github.com/thomasnield/RxKotlinFX'\n\n                scm {\n                    connection 'scm:git:git://github.com/thomasnield/RxKotlinFX.git'\n                    developerConnection 'scm:git:git@github.com:thomasnield/RxKotlinFX.git'\n                    url 'https://github.com/thomasnield/RxKotlinFX.git'\n                }\n\n                licenses {\n                    license {\n                        name 'The Apache License, Version 2.0'\n                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'\n                    }\n                }\n                developers {\n                    developer {\n                        id 'thomasnield'\n                        name 'Thomas Nield'\n                        email 'thomasnield@live.com'\n                    }\n                }\n            }\n        }\n    }\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sat Feb 25 20:14:08 CST 2017\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.10-all.zip\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "src/main/kotlin/com/github/thomasnield/rxkotlinfx/Nodes.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.Observable\nimport javafx.scene.control.*\n\n/**\n * Returns an [Observable] emitting integer values for selected row indexes.\n */\nval <T> TableView<T>.rowIndexSelections: Observable<Int>\n    get() = itemSelections.map { selectionModel.selectedIndex }\n\n/**\n * Returns an [Observable] emitting integer values for selected column indexes.\n */\nval <T> TableView<T>.columnIndexSelections: Observable<Int>\n    get() = selectionModel.selectedCells\n            .additions().map { it.column }\n\n/**\n * Returns an [Observable] emitting selected items for the given TableView\n */\nval <T> TableView<T>.itemSelections: Observable<T>\n    get() = selectionModel.selectedItemProperty().toObservable()\n\n/**\n * Returns an [Observable] emitting single selected items for the given [ListView]\n */\nval <T> ListView<T>.itemSelections: Observable<T>\n    get() = selectionModel.selectedItems.additions()\n\n/**\n * Returns an [Observable] emitting single selected items for the given [ComboBox]\n */\nval <T> ComboBox<T>.valueSelections: Observable<T>\n    get() = valueProperty().toObservable()\n\n/**\n * Returns an [Observable] emitting text value inputs for the given [TextField]\n */\nval TextField.textValues: Observable<String>\n        get() = textProperty().toObservable()\n\n/**\n * Returns an [Observable] emitting [Tab] selections for the given [TabPane]\n */\nval TabPane.tabSelections: Observable<Tab>\n        get() = selectionModel.selectedItemProperty().toObservable()\n"
  },
  {
    "path": "src/main/kotlin/com/github/thomasnield/rxkotlinfx/Observables.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.Flowable\nimport io.reactivex.Maybe\nimport io.reactivex.Observable\nimport io.reactivex.Single\nimport io.reactivex.rxjavafx.observables.JavaFxObservable\nimport io.reactivex.rxjavafx.observers.JavaFxObserver\nimport io.reactivex.rxjavafx.observers.JavaFxSubscriber\nimport io.reactivex.rxjavafx.sources.SetChange\nimport javafx.beans.binding.Binding\nimport javafx.beans.value.ObservableValue\nimport javafx.collections.ObservableList\nimport javafx.collections.ObservableMap\nimport javafx.collections.ObservableSet\nimport javafx.event.Event\nimport javafx.event.EventType\nimport javafx.scene.Node\nimport javafx.scene.Scene\nimport javafx.scene.control.ContextMenu\nimport javafx.scene.control.Dialog\nimport javafx.scene.control.MenuItem\nimport javafx.stage.Window\nimport javafx.stage.WindowEvent\nimport java.util.*\n\n/**\n * Turns an Observable into a JavaFX Binding. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Observable<T>.toBinding(actionOp: (ObservableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxObserver.toBinding((transformer?.let { this.compose(it) }?:this))\n}\n\n\n/**\n * Turns an Flowable into a JavaFX Binding. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Flowable<T>.toBinding(actionOp: (FlowableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = FlowableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxSubscriber.toBinding((transformer?.let { this.compose(it) }?:this))\n}\n\n/**\n * Turns an Observable into a JavaFX Binding with a nullSentinel `T` acting as a placeholder for null values. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Observable<T>.toNullBinding(nullSentinel: T, actionOp: (ObservableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxObserver.toNullBinding((transformer?.let { this.compose(it) }?:this), nullSentinel)\n}\n\n\n/**\n * Turns an Flowable into a JavaFX Binding with a nullSentinel `T` acting as a placeholder for null values. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Flowable<T>.toNullBinding(nullSentinel: T, actionOp: (FlowableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = FlowableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxSubscriber.toNullBinding((transformer?.let { this.compose(it) }?:this), nullSentinel)\n}\n\n\n/**\n * Turns an Observable into a JavaFX Binding that automatically unwraps the Optional to a nullable value. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Observable<Optional<T>>.toNullableBinding(actionOp: (ObservableBindingSideEffects<Optional<T>>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<Optional<T>>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxObserver.toNullableBinding((transformer?.let { this.compose(it) }?:this))\n}\n\n\n/**\n * Turns an `Flowable<Optional<T>>` into a JavaFX Binding that automatically unwraps the Optional to a nullable value. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Flowable<Optional<T>>.toNullableBinding(actionOp: (FlowableBindingSideEffects<Optional<T>>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = FlowableBindingSideEffects<Optional<T>>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxSubscriber.toNullableBinding((transformer?.let { this.compose(it) }?:this))\n}\n\n\n/**\n * Turns an Observable into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Observable<T>.toLazyBinding() = JavaFxObserver.toLazyBinding(this)\n\n\n/**\n * Turns a Flowable into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Flowable<T>.toLazyBinding() = JavaFxSubscriber.toLazyBinding(this)\n\n\n\n/**\n * Turns an `Observable<Optional<T>>` into a lazy JavaFX Binding that automatically unwraps the Optional to a nullable value, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Observable<Optional<T>>.toLazyNullableBinding() = JavaFxObserver.toLazyNullableBinding(this)\n\n\n/**\n * Turns a `Flowable<Optional<T>>` into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Flowable<Optional<T>>.toLazyNullableBinding() = JavaFxSubscriber.toLazyNullableBinding(this)\n\n/**\n * Turns a Single into a JavaFX Binding. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Single<T>.toBinding(actionOp: (ObservableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxObserver.toBinding((transformer?.let { this.toObservable().compose(it) }?:this.toObservable()))\n}\n\n/**\n * Turns a Single into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Single<T>.toLazyBinding() = JavaFxObserver.toLazyBinding(this.toObservable())\n\n\n/**\n * Turns a `Single<Optional<T>>` into a lazy JavaFX Binding that automatically unwraps the Optional to a nullable value, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Single<Optional<T>>.toLazyNullableBinding() = JavaFxObserver.toLazyNullableBinding(this.toObservable())\n\n\n/**\n * Turns a Maybe into a JavaFX Binding. Calling the Binding's dispose() method will handle the disposal.\n */\nfun <T> Maybe<T>.toBinding(actionOp: (ObservableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    return JavaFxObserver.toBinding((transformer?.let { this.toObservable().compose(it) }?:this.toObservable()))\n}\n\n/**\n * Turns a Maybe into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Maybe<T>.toLazyBinding() = JavaFxObserver.toLazyBinding(this.toObservable())\n\n/**\n * Turns a `Maybe<Optional<T>>` into a lazy JavaFX Binding that automatically unwraps the Optional to a nullable value, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Maybe<Optional<T>>.toLazyNullableBinding() = JavaFxObserver.toLazyNullableBinding(this.toObservable())\n\n\n\n/**\n * Turns an Observable into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Observable<T>.toLazyBinding(errorHandler: (Throwable) -> Unit) = JavaFxObserver.toLazyBinding(this,errorHandler)\n\n/**\n * Turns a Flowable into a lazy JavaFX Binding, by lazy meaning it will delay subscription until `getValue()` is requested. Calling the Binding's dispose() method will handle the unsubscription.\n */\nfun <T> Flowable<T>.toLazyBinding(errorHandler: (Throwable) -> Unit) = JavaFxSubscriber.toLazyBinding(this,errorHandler)\n\n\n/**\n * Create an rx Observable from a javafx ObservableValue\n * @param <T>          the type of the observed value\n * @return an Observable emitting values as the wrapped ObservableValue changes\n */\nfun <T> ObservableValue<T>.toObservable() = JavaFxObservable.valuesOf(this)\n\n/**\n * Create an rx Observable from a javafx ObservableValue\n * @param <T>          the type of the observed value\n * @param nullSentinel the default sentinel value emitted when the observable is null\n * @return an Observable emitting values as the wrapped ObservableValue changes\n */\nfun <T> ObservableValue<T>.toObservable(nullSentinel: T) = JavaFxObservable.valuesOf(this, nullSentinel)\n\n\n/**\n * Create an rx Observable from a javafx ObservableValue, emitting nullable values as Java 8 `Optional` types\n * @param <T>          the type of the observed value\n * @return an Observable emitting `Optional<T>` values as the wrapped ObservableValue changes\n */\nfun <T> ObservableValue<T>.toNullableObservable() = JavaFxObservable.nullableValuesOf(this)\n\n/**\n * Create an rx Observable from a javafx Observable, emitting it when an invalidation occursk\n * @return an rx Observable emitting the JavaFX Observable every time it is invalidated\n */\nfun javafx.beans.Observable.invalidations() = JavaFxObservable.invalidationsOf(this)\n\n/**\n * Create an rx Observable from a javafx ObservableValue, and emits changes with old and new value pairs\n * @param <T>          the type of the observed value\n * @return an Observable emitting values as the wrapped ObservableValue changes\n */\nfun <T> ObservableValue<T>.toObservableChanges() = JavaFxObservable.changesOf(this)\n\n/**\n * Create an rx Observable from a javafx ObservableValue, and emits changes with old and new non-null value pairs\n * @param <T>          the type of the observed value\n * @return an Observable emitting non-null values as the wrapped ObservableValue changes\n */\nfun <T> ObservableValue<T>.toObservableChangesNonNull() = JavaFxObservable.nonNullChangesOf(this)\n\n\n/**\n * Creates an observable corresponding to javafx ContextMenu action events.\n * @return An Observable of UI ActionEvents\n */\nfun ContextMenu.actionEvents() = JavaFxObservable.actionEventsOf(this)\n\n/**\n * Creates an observable corresponding to javafx MenuItem action events.\n *\n * @param menuItem      The target of the ActionEvents\n * @return An Observable of UI ActionEvents\n */\nfun MenuItem.actionEvents() = JavaFxObservable.actionEventsOf(this)\n\n/**\n * Creates an observable corresponding to javafx Node action events.\n * @return An Observable of UI ActionEvents\n */\nfun Node.actionEvents() = JavaFxObservable.actionEventsOf(this)\n\n/**\n * Creates an observable corresponding to javafx Node events.\n * @param eventType The type of the observed UI events\n * @return An Observable of UI events, appropriately typed\n */\nfun <T : Event> Node.events(eventType: EventType<T>) = JavaFxObservable.eventsOf(this, eventType)\n/**\n * Create an rx Observable from a javafx ObservableValue\n * @param <T>          the type of the observed value\n * @return an Observable emitting values as the wrapped ObservableValue changes\n */\nfun <T: Event> Scene.events(eventType: EventType<T>) = JavaFxObservable.eventsOf(this,eventType)\n/**\n * Create an rx Observable from a javafx ObservableValue, and emits changes with old and new value pairs\n * @param <T>          the type of the observed value\n * @return an Observable emitting values as the wrapped ObservableValue changes\n */\nfun <T: WindowEvent> Window.events(eventType: EventType<T>) = JavaFxObservable.eventsOf(this,eventType)\n\n/**\n * Creates an observable that emits an ObservableList every time it is modified\n * @return An Observable emitting the ObservableList each time it changes\n */\nfun <T> ObservableList<T>.onChangedObservable() = JavaFxObservable.emitOnChanged(this)\n\n/**\n * Creates an observable that emits all removal items from an ObservableList\n * @return An Observable emitting items removed from the ObservableList\n */\nfun <T> ObservableList<T>.removals() = JavaFxObservable.removalsOf(this)\n/**\n * Creates an observable that emits all additions to an ObservableList\n * @return An Observable emitting items added to the ObservableList\n */\nfun <T> ObservableList<T>.additions() = JavaFxObservable.additionsOf(this)\n/**\n * Creates an observable that emits all updated items from an ObservableList.\n * If you declare an ObservableList that listens to one or more properties of each element,\n * you can emit the changed items every time these properties are modified\n * <pre>ObservableList<Person> sourceList = FXCollections.observableArrayList(user -> new javafx.beans.Observable[]{user.age} );</pre>\n * @return An Observable emitting items updated in the ObservableList\n */\nfun <T> ObservableList<T>.updates() = JavaFxObservable.updatesOf(this)\n/**\n * Emits all added, removed, and updated items from an ObservableList\n * @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <T> ObservableList<T>.changes() = JavaFxObservable.changesOf(this)\n\n/**\n * Emits distinctly  added and removed items from an ObservableList.\n * If dupe items with identical hashcode/equals evaluations are added to an ObservableList, only the first one will fire an ADDED item.\n * When the last dupe is removed, only then will it fire a REMOVED item.\n * @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <T> ObservableList<T>.distinctChanges() = JavaFxObservable.distinctChangesOf(this)\n/**\n * Emits distinctly added and removed items item from an ObservableList.\n * 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.\n * When the last dupe is removed, only then will it fire a REMOVED T item.\n * @return An Observable emitting changed mapped items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <T,R> ObservableList<T>.distinctChanges(mapper: ((T) -> R)) = JavaFxObservable.distinctChangesOf(this,mapper)\n\n/**\n * Emits distinctly added and removed mappings to each R item from an ObservableList.\n * 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.\n * When the last dupe is removed, only then will it fire a REMOVED R item.\n * @return An Observable emitting changed mapped items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <T,R> ObservableList<T>.distinctMappingChanges(mapper: ((T) -> R)) = JavaFxObservable.distinctMappingsOf(this,mapper)\n\n/**\n * Creates an observable that emits an ObservableMap every time it is modified\n * @return An Observable emitting the ObservableMap each time it changes\n */\nfun <K,T> ObservableMap<K, T>.onChangedObservable() = JavaFxObservable.emitOnChanged(this)\n/**\n * Creates an observable that emits all removal items from an ObservableMap\n * @return An Observable emitting items removed from the ObservableMap\n */\nfun <K,T> ObservableMap<K, T>.removals() = JavaFxObservable.removalsOf(this)\n/**\n * Creates an observable that emits all additions to an ObservableMap\n * @return An Observable emitting items added to the ObservableMap\n */\nfun <K,T> ObservableMap<K, T>.additions() = JavaFxObservable.additionsOf(this)\n/**\n * Emits all added, removed, and updated items from an ObservableMap\n * @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <K,T> ObservableMap<K, T>.changes() = JavaFxObservable.changesOf(this)\n\n/**\n * Creates an observable that emits an ObservableSet every time it is modified\n * @return An Observable emitting the ObservableSet each time it changes\n */\nfun <T> ObservableSet<T>.onChangedObservable() = JavaFxObservable.emitOnChanged(this)\n\n/**\n * Creates an observable that emits all removal items from an ObservableSet\n * @return An Observable emitting items removed from the ObservableSet\n */\nfun <T> ObservableSet<T>.removals() = JavaFxObservable.removalsOf(this)\n/**\n * Creates an observable that emits all additions to an ObservableSet\n * @return An Observable emitting items added to the ObservableSet\n */\nfun <T> ObservableSet<T>.additions() = JavaFxObservable.additionsOf(this)\n/**\n * Emits all added, removed, and updated items from an ObservableSet\n * @return An Observable emitting changed items with an ADDED, REMOVED, or UPDATED flags\n */\nfun <T> ObservableSet<SetChange<T>>.changes() = JavaFxObservable.changesOf(this)\n\n\n/**\n * Emits the response `T` for a given `Dialog<T>`. If no response is provided the Maybe  will be empty.\n */\nfun <T> Dialog<T>.toMaybe() = JavaFxObservable.fromDialog(this)!!"
  },
  {
    "path": "src/main/kotlin/com/github/thomasnield/rxkotlinfx/Operators.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.*\nimport io.reactivex.rxjavafx.schedulers.JavaFxScheduler\nimport io.reactivex.rxjavafx.transformers.FxFlowableTransformers\nimport io.reactivex.rxjavafx.transformers.FxObservableTransformers\nimport javafx.application.Platform\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Observable#observeOn(JavaFxScheduler.platform())\n */\nfun <T> Observable<T>.observeOnFx() = observeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Flowable#observeOn(JavaFxScheduler.platform())\n */\nfun <T> Flowable<T>.observeOnFx() = observeOn(JavaFxScheduler.platform())\n\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Single#observeOn(JavaFxScheduler.platform())\n */\nfun <T> Single<T>.observeOnFx() = observeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Maybe#observeOn(JavaFxScheduler.platform())\n */\nfun <T> Maybe<T>.observeOnFx() = observeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Completable#observeOn(JavaFxScheduler.platform())\n */\nfun Completable.observeOnFx() = observeOn(JavaFxScheduler.platform())\n\n\n/**\n * Instructs the source Observable to emit items on the JavaFX Thread.\n * This is the same as calling Observable#subscribeOn(JavaFxScheduler.platform())\n */\nfun <T> Observable<T>.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())\n\n/**\n * Instructs the source Flowable to emit items on the JavaFX Thread.\n * This is the same as calling Flowable#subscribeOn(JavaFxScheduler.platform())\n */\nfun <T> Flowable<T>.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Single#subscribeOnFx(JavaFxScheduler.platform())\n */\nfun <T> Single<T>.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Maybe#subscribeOnFx(JavaFxScheduler.platform())\n */\nfun <T> Maybe<T>.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())\n\n/**\n * Observes the emissions on the JavaFX Thread.\n * This is the same as calling Completable#subscribeOnFx(JavaFxScheduler.platform())\n */\nfun Completable.subscribeOnFx() = subscribeOn(JavaFxScheduler.platform())\n\n/**\n * Performs the provided onNext action on the FX thread\n */\ninline fun <T> Observable<T>.doOnNextFx(crossinline onNext: (T) -> Unit): Observable<T> = doOnNext {\n    Platform.runLater { onNext.invoke(it) }\n}\n\n/**\n * Performs the provided onNext action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnNextFx(crossinline onNext: (T) -> Unit): Flowable<T> = doOnNext {\n    Platform.runLater { onNext.invoke(it) }\n}\n\n/**\n * Performs the provided onError action on the FX thread\n */\ninline fun <T> Observable<T>.doOnErrorFx(crossinline onError: (Throwable) -> Unit): Observable<T> = doOnError {\n    Platform.runLater { onError.invoke(it) }\n}\n\n/**\n * Performs the provided onError action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnErrorFx(crossinline onError: (Throwable) -> Unit): Flowable<T> = doOnError {\n    Platform.runLater { onError.invoke(it) }\n}\n\n/**\n * Performs the provided onComplete action on the FX thread\n */\ninline fun <T> Observable<T>.doOnCompleteFx(crossinline onComplete: () -> Unit): Observable<T> = doOnComplete {\n    Platform.runLater { onComplete.invoke() }\n}\n\n/**\n * Performs the provided onComplete action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnCompleteFx(crossinline onComplete: () -> Unit): Flowable<T> = doOnComplete {\n    Platform.runLater { onComplete.invoke() }\n}\n\n/**\n * Performs the provided onSubscribe action on the FX thread\n */\ninline fun <T> Observable<T>.doOnSubscribeFx(crossinline onSubscribe: () -> Unit): Observable<T> = doOnSubscribe {\n    Platform.runLater { onSubscribe.invoke() }\n}\n\n\n/**\n * Performs the provided onSubscribe action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnSubscribeFx(crossinline onSubscribe: () -> Unit): Flowable<T> = doOnSubscribe {\n    Platform.runLater { onSubscribe.invoke() }\n}\n\n/**\n * Performs the provided onTerminate action on the FX thread\n */\ninline fun <T> Observable<T>.doOnTerminateFx(crossinline onTerminate: () -> Unit): Observable<T> = doOnTerminate {\n    Platform.runLater { onTerminate.invoke() }\n}\n\n/**\n * Performs the provided onTerminate action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnTerminateFx(crossinline onTerminate: () -> Unit): Flowable<T> = doOnTerminate {\n    Platform.runLater { onTerminate.invoke() }\n}\n\n/**\n * Performs the provided onDispose action on the FX thread\n */\ninline fun <T> Observable<T>.doOnDisposeFx(crossinline onDispose: () -> Unit): Observable<T> = this.doOnDispose {\n    Platform.runLater { onDispose.invoke() }\n}\n\n/**\n * Performs the provided onDispose action on the FX thread\n */\ninline fun <T> Flowable<T>.doOnCancelFx(crossinline onDispose: () -> Unit): Flowable<T> = this.doOnCancel {\n    Platform.runLater { onDispose.invoke() }\n}\n\n/**\n * Executes side effect with the accumulating count of emissions for each onNext() call\n */\nfun <T> Observable<T>.doOnNextCount(onNext: (Int) -> Unit): Observable<in T> =\n        compose(FxObservableTransformers.doOnNextCount(onNext))\n\n\n/**\n * Executes side effect with the accumulating count of emissions for each onNext() call\n */\nfun <T> Flowable<T>.doOnNextCount(onNext: (Int) -> Unit): Flowable<in T> =\n        compose(FxFlowableTransformers.doOnNextCount(onNext))\n\n/**\n * Executes side effect with the total count of emissions for the onComplete() call\n */\nfun <T> Observable<T>.doOnCompleteCount(onComplete: (Int) -> Unit): Observable<in T> =\n        compose(FxObservableTransformers.doOnCompleteCount(onComplete))\n\n/**\n * Executes side effect with the total count of emissions for the onComplete() call\n */\nfun <T> Flowable<T>.doOnCompleteCount(onComplete: (Int) -> Unit): Flowable<in T> =\n        compose(FxFlowableTransformers.doOnCompleteCount(onComplete))\n\n/**\n * Executes side effect with the total count of emissions for an onError() call\n */\nfun <T> Observable<T>.doOnErrorCount(onError: (Int) -> Unit): Observable<in T> =\n        compose(FxObservableTransformers.doOnErrorCount(onError))\n\n/**\n * Executes side effect with the total count of emissions for an onError() call\n */\nfun <T> Flowable<T>.doOnErrorCount(onError: (Int) -> Unit): Flowable<in T> =\n        compose(FxFlowableTransformers.doOnErrorCount(onError))\n\n/**\n * Executes side effect on FX thread with the accumulating count of emissions for each onNext() call\n */\nfun <T> Observable<T>.doOnNextCountFx(onNext: (Int) -> Unit) = doOnNextCount { Platform.runLater { onNext.invoke(it) } }\n\n/**\n * Executes side effect on FX thread with the accumulating count of emissions for each onNext() call\n */\nfun <T> Flowable<T>.doOnNextCountFx(onNext: (Int) -> Unit) = doOnNextCount { Platform.runLater { onNext.invoke(it) } }\n\n/**\n * Executes side effect on FX thread with the total count of emissions for the onComplete() call\n */\nfun <T> Observable<T>.doOnCompleteCountFx(onComplete: (Int) -> Unit) = doOnCompleteCount { Platform.runLater { onComplete.invoke(it) } }\n\n/**\n * Executes side effect on FX thread with the total count of emissions for the onComplete() call\n */\nfun <T> Flowable<T>.doOnCompleteCountFx(onComplete: (Int) -> Unit) = doOnCompleteCount { Platform.runLater { onComplete.invoke(it) } }\n\n/**\n * Executes side effect on FX thread with the total count of emissions for the onError() call\n */\nfun <T> Observable<T>.doOnErrorCountFx(onError: (Int) -> Unit) = doOnErrorCount { Platform.runLater { onError.invoke(it) } }\n\n\n/**\n * Executes side effect on FX thread with the total count of emissions for the onError() call\n */\nfun <T> Flowable<T>.doOnErrorCountFx(onError: (Int) -> Unit) = doOnErrorCount { Platform.runLater { onError.invoke(it) } }"
  },
  {
    "path": "src/main/kotlin/com/github/thomasnield/rxkotlinfx/Subscribers.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.Flowable\nimport io.reactivex.FlowableTransformer\nimport io.reactivex.Observable\nimport io.reactivex.ObservableTransformer\nimport io.reactivex.rxjavafx.subscriptions.CompositeBinding\nimport javafx.beans.binding.Binding\nimport javafx.beans.property.Property\n\n\n/**\n * Binds the `Property` to an RxJava `Observable`,\n * meaning it will be bounded to show the latest emissions of that `Observable`.\n * The `Binding` is also returned so caller can be dispose it later if needed\n * @return `Binding`\n */\nfun <T> Property<T>.bind(observable: Observable<T>, actionOp: (ObservableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = ObservableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    val binding = (transformer?.let { observable.compose(it) }?:observable).toBinding()\n    bind(binding)\n    return binding\n}\n\n/**\n * Binds the `Property` to an RxJava `Flowable`,\n * meaning it will be bounded to show the latest emissions of that `Flowable`.\n * The `Binding` is also returned so caller can be dispose it later if needed\n * @return `Binding`\n */\nfun <T> Property<T>.bind(flowable: Flowable<T>, actionOp: (FlowableBindingSideEffects<T>.() -> Unit)? = null): Binding<T> {\n    val transformer = actionOp?.let {\n        val sideEffects = FlowableBindingSideEffects<T>()\n        it.invoke(sideEffects)\n        sideEffects.transformer\n    }\n    val binding = (transformer?.let { flowable.compose(it) }?:flowable).toBinding()\n    bind(binding)\n    return binding\n}\nfun <T> Binding<T>.addTo(compositeBinding: CompositeBinding): Binding<T> {\n    compositeBinding.add(this)\n    return this\n}\n\noperator fun <T> CompositeBinding.plusAssign(binding: Binding<T>) = add(binding)\n\noperator fun CompositeBinding.plusAssign(compositeBinding: CompositeBinding) = add(compositeBinding)\n\noperator fun <T> CompositeBinding.minusAssign(binding: Binding<T>) = remove(binding)\n\noperator fun CompositeBinding.minusAssign(compositeBinding: CompositeBinding) = remove(compositeBinding)\n\nclass ObservableBindingSideEffects<T> {\n    private var onNextAction: ((T) -> Unit)? = null\n    private var onCompleteAction: (() -> Unit)? = null\n    private var onErrorAction: ((ex: Throwable) -> Unit)? = null\n\n    fun onNext(onNext: (T) -> Unit): Unit {\n        onNextAction = onNext\n    }\n\n    fun onComplete(onComplete: () -> Unit): Unit {\n        onCompleteAction = onComplete\n    }\n\n    fun onError(onError: (ex: Throwable) -> Unit): Unit {\n        onErrorAction = onError\n    }\n\n    internal val transformer: ObservableTransformer<T, T> get() = ObservableTransformer<T, T> { obs ->\n        var withActions: Observable<T> = obs\n        withActions = onNextAction?.let { withActions.doOnNext(onNextAction) } ?: withActions\n        withActions = onCompleteAction?.let { withActions.doOnComplete(onCompleteAction) } ?: withActions\n        withActions = onErrorAction?.let { withActions.doOnError(onErrorAction) } ?: withActions\n        withActions\n    }\n}\n\n\nclass FlowableBindingSideEffects<T> {\n    private var onNextAction: ((T) -> Unit)? = null\n    private var onCompleteAction: (() -> Unit)? = null\n    private var onErrorAction: ((ex: Throwable) -> Unit)? = null\n\n    fun onNext(onNext: (T) -> Unit): Unit {\n        onNextAction = onNext\n    }\n\n    fun onComplete(onComplete: () -> Unit): Unit {\n        onCompleteAction = onComplete\n    }\n\n    fun onError(onError: (ex: Throwable) -> Unit): Unit {\n        onErrorAction = onError\n    }\n\n    internal val transformer: FlowableTransformer<T, T> get() = FlowableTransformer<T, T> { obs ->\n        var withActions: Flowable<T> = obs\n        withActions = onNextAction?.let { withActions.doOnNext(onNextAction) } ?: withActions\n        withActions = onCompleteAction?.let { withActions.doOnComplete(onCompleteAction) } ?: withActions\n        withActions = onErrorAction?.let { withActions.doOnError(onErrorAction) } ?: withActions\n        withActions\n    }\n}"
  },
  {
    "path": "src/main/kotlin/com/github/thomasnield/rxkotlinfx/Util.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.Observable\nimport java.util.*\n\n@Deprecated(\"Don't use this anymore. Implement yourself.\", ReplaceWith(\"Single.just(this).filter { it.isPresent }.map { it.get() }\", \"io.reactivex.Observable\"))\nfun <T> Optional<T>.toObservable() = Observable.just(this)\n        .filter { it.isPresent }\n        .map { it.get() }"
  },
  {
    "path": "src/test/kotlin/com/github/thomasnield/rxkotlinfx/OperatorsTest.kt",
    "content": "package com.github.thomasnield.rxkotlinfx\n\nimport io.reactivex.Observable\nimport io.reactivex.schedulers.Schedulers\nimport javafx.application.Platform\nimport javafx.embed.swing.JFXPanel\nimport org.junit.Assert.assertTrue\nimport java.util.*\nimport java.util.concurrent.CountDownLatch\nimport java.util.concurrent.TimeUnit\nimport java.util.concurrent.atomic.AtomicInteger\n\nclass OperatorsTest {\n\n    init {\n        JFXPanel()\n    }\n    @org.junit.Test\n    fun doOnNextFxTest() {\n        val latch = CountDownLatch(1)\n\n        Observable.just(\"Alpha\").observeOn(Schedulers.io()).doOnNextFx {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n    }\n    @org.junit.Test\n    fun doOnCompletedFxTest() {\n        val latch = CountDownLatch(1)\n\n        Observable.just(\"Alpha\").observeOn(Schedulers.io()).doOnCompleteFx() {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n    }\n\n    @org.junit.Test\n    fun doOnSubscribeFx() {\n        val latch = CountDownLatch(1)\n\n        Observable.just(\"Alpha\").observeOn(Schedulers.io()).doOnSubscribeFx {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n    }\n\n    @org.junit.Test\n    fun doOnTerminateFx() {\n        val latch = CountDownLatch(1)\n\n        Observable.just(\"Alpha\").observeOn(Schedulers.io()).doOnTerminateFx {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n    }\n\n    @org.junit.Test\n    fun doOnUnsubscribeFxTest() {\n        val latch = CountDownLatch(1)\n\n        val subscription = Observable.interval(1, TimeUnit.SECONDS).doOnDisposeFx {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.subscribe()\n\n        Thread.sleep(3000)\n        subscription.dispose()\n\n        latch.await(10, TimeUnit.SECONDS)\n    }\n    @org.junit.Test\n    fun doOnErrorFxTest() {\n        val latch = CountDownLatch(1)\n\n        Observable.just(5).map { it / 0 }.observeOn(Schedulers.io()).doOnErrorFx {\n            assertTrue(Platform.isFxApplicationThread())\n            latch.countDown()\n        }.onErrorResumeNext(Observable.empty()).subscribe()\n\n        latch.await()\n    }\n    @org.junit.Test\n    fun doOnNextCountTest() {\n        val items: MutableList<Int> = ArrayList()\n\n        Observable.just(\"Alpha\",\"Beta\",\"Gamma\")\n            .doOnNextCount { items.add(it) }\n            .subscribe()\n\n        assertTrue(items.containsAll(listOf(1,2,3)))\n    }\n    @org.junit.Test\n    fun doOnCompletedCountTest() {\n\n        var value: Int? = null\n        Observable.just(\"Alpha\",\"Beta\",\"Gamma\")\n                .doOnCompleteCount { value = it }\n                .subscribe()\n\n        assertTrue(value != null && value == 3)\n    }\n    @org.junit.Test\n    fun doOnErrorCountTest() {\n\n        var value: Int? = null\n        Observable.just(1,2,0,3)\n                .map { 10 / it }\n                .doOnErrorCount { value = it }\n                .subscribe()\n\n        assertTrue(value != null && value == 2)\n    }\n    @org.junit.Test\n    fun doOnNextCountFxTest() {\n        val latch = CountDownLatch(3)\n        var sum: Int = 0\n        Observable.just(1,2,3)\n            .doOnNextCountFx {\n                assertTrue(Platform.isFxApplicationThread())\n                sum += it\n                latch.countDown()\n            }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n        assert(sum == 6)\n    }\n    @org.junit.Test\n    fun doOnCompletedCountFxTest() {\n        val latch = CountDownLatch(1)\n        var value: Int? = null\n        Observable.just(\"Alpha\",\"Beta\",\"Gamma\")\n                .doOnCompleteCountFx {\n                    assertTrue(Platform.isFxApplicationThread())\n                    value = it\n                    latch.countDown()\n                }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n        assertTrue(value == 3)\n    }\n    @org.junit.Test\n    fun doOnErrorCountFxTest() {\n        val latch = CountDownLatch(1)\n        var value: Int? = null\n        Observable.just(1,3,0,5)\n                .map { 10 / it }\n                .doOnErrorCountFx {\n                    assertTrue(Platform.isFxApplicationThread())\n                    value = it\n                    latch.countDown()\n                }.subscribe()\n\n        latch.await(10, TimeUnit.SECONDS)\n        assertTrue(value == 2)\n    }\n\n    @org.junit.Test\n    fun bindingSideEffectsTest() {\n        val counter = AtomicInteger(0)\n        Observable.just(1,2,3)\n                .toBinding {\n                    onNext { counter.incrementAndGet() }\n                    onComplete { counter.incrementAndGet() }\n                }\n\n        assertTrue(counter.get() == 4)\n    }\n\n    @org.junit.Test\n    fun bindingSideEffectsErrorTest() {\n        val counter = AtomicInteger(0)\n        Observable.error<Unit>(Exception(\"Test\"))\n                .toBinding {\n                    onError { counter.incrementAndGet() }\n                }\n\n       assertTrue(counter.get() == 1)\n    }\n}"
  }
]