Add documentation to observableSink

This commit is contained in:
Sarah Gerweck 2016-04-18 21:14:03 -07:00
parent fb2dac9b3f
commit eb00380441
2 changed files with 47 additions and 0 deletions

View File

@ -198,6 +198,15 @@ object Eclipse {
} }
object Dependencies { object Dependencies {
/* ********************************************************************** */
/* Akka */
/* ********************************************************************** */
final val akkaVersion = "2.4.4"
val akkaActor = "com.typesafe.akka" %% "akka-actor" % akkaVersion
val akkaAgent = "com.typesafe.akka" %% "akka-agent" % akkaVersion
val akkaStream = "com.typesafe.akka" %% "akka-stream" % akkaVersion
/* ********************************************************************** */ /* ********************************************************************** */
/* Utility Dependencies */ /* Utility Dependencies */
/* ********************************************************************** */ /* ********************************************************************** */
@ -319,6 +328,13 @@ object UtilsBuild extends Build {
shapeless shapeless
), ),
/* Akka dependencies */
libraryDependencies ++= Seq (
akkaActor % "optional",
akkaStream % "optional",
akkaAgent % "optional"
),
unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/jre/lib/ext/jfxrt.jar")) unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/jre/lib/ext/jfxrt.jar"))
) )
} }

View File

@ -0,0 +1,31 @@
package org.gerweck.scalafx.akka
import scala.concurrent.Future
import akka.Done
import akka.stream.scaladsl._
import scalafx.application.Platform.runLater
import scalafx.beans.property.Property
/** A master object that exposes all the Akka-ScalaFX bridges.
*
* @author Sarah Gerweck <sarah.a180@gmail.com>
*/
object AkkaFX extends AkkaStreamFX
trait AkkaStreamFX {
/** A [[akka.stream.scaladsl.Sink]] that sends all values to a
* [[scalafx.beans.property.Property]].
*
* Each event that's written into the `Sink` will trigger an update of the
* `Property` with the streamed value.
*/
def observableSink[A](prop: Property[A, _]): Sink[A, Future[Done]] = {
Sink.foreach[A] { a =>
runLater {
prop.value = a
}
}
}
}