Add documentation to observableSink
This commit is contained in:
parent
fb2dac9b3f
commit
eb00380441
@ -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"))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
31
src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala
Normal file
31
src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user