package binding
- Alphabetic
- Public
- All
Type Members
-
trait
Binding[+A] extends AnyRef
A data binding expression that represents a value that automatically recalculates when its dependencies change.
A data binding expression that represents a value that automatically recalculates when its dependencies change.
Author:
杨博 (Yang Bo) <[email protected]>
You may create a data binding expression via
Binding { ??? }
block or@dom
annotation.val bindingInt: Binding[Int] = Binding { 100 }
@dom val bindingBr: Binding[HTMLBRElement] = <br/>
A data binding expression may depend on other binding expressions via bind method:
val bindingString: Binding[String] = Binding { bindingInt.bind.toString }
Example: -
final
class
FutureBinding[A] extends Binding[Option[Try[A]]]
A wrapper that wraps scala.concurrent.Future to a Binding.
A wrapper that wraps scala.concurrent.Future to a Binding.
- Note
Because all Binding (including this FutureBinding) are not thread safe, you must guarantee
executor
running sequentially.
-
final
class
JsPromiseBinding[A] extends Binding[Option[Either[Any, A]]]
A wrapper that wraps a scala.scalajs.js.Thenable to a com.thoughtworks.binding.Binding.
A wrapper that wraps a scala.scalajs.js.Thenable to a com.thoughtworks.binding.Binding.
Author:
杨博 (Yang Bo) <[email protected]>
This JsPromiseBinding will cache the result of the
thenable
. Given a scala.scalajs.js.Thenable that will be delay executed.import scala.scalajs.js var upstreamEvaluationCount1 = 0 val delayedThenable = js.Promise.resolve[Unit](()).`then`[Double] { case () => upstreamEvaluationCount1 += 1 math.random }
The execution will not be performed right now.
val jsPromiseBinding = JsPromiseBinding(delayedThenable) upstreamEvaluationCount1 should be(0)
When there are multiple usages of
jsPromiseBinding
, each usage should be triggered with the same value.var evaluationCount1 = 0 var evaluationCount2 = 0 var evaluationCount3 = 0 val usage1 = Binding { jsPromiseBinding.bind match { case Some(Right(value)) => evaluationCount1 += 1 case _ => } } val usage2 = Binding { jsPromiseBinding.bind match { case Some(Right(value)) => evaluationCount2 += 1 val usage3 = Binding { jsPromiseBinding.bind match { case Some(Right(value)) => evaluationCount3 += 1 case _ => } } val _ = usage1.bind usage3.bind case _ => } } usage2.watch() upstreamEvaluationCount1 should be(0) evaluationCount1 should be(0) evaluationCount2 should be(0) evaluationCount3 should be(0)
And each usage should be triggered once and only once.
delayedThenable.toFuture.map { _ => upstreamEvaluationCount1 should be(1) evaluationCount1 should be(1) evaluationCount2 should be(1) evaluationCount3 should be(1) }
Example: -
final
class
SafeBuffer[A] extends Buffer[A]
Similar to scala.collection.mutable.ArrayBuffer, except that this SafeBuffer allows adding or removing elements via += and -= inside a foreach block.
Similar to scala.collection.mutable.ArrayBuffer, except that this SafeBuffer allows adding or removing elements via += and -= inside a foreach block.
- Note
A java.lang.IllegalStateException will be thrown when invoking methods other than += and -= in a foreach block.
-
trait
XmlExtractor extends AnyRef
Author:
杨博 (Yang Bo) <[email protected]>
-
macro
class
dom extends Annotation with StaticAnnotation
Enable XML DOM literal for Binding.scala
Enable XML DOM literal for Binding.scala
Author:
杨博 (Yang Bo) <[email protected]>
- Annotations
- @compileTimeOnly( ... )
-
macro
class
fxml extends Annotation with StaticAnnotation
An annotation to convert FXML literals to JavaFX GUI.
An annotation to convert FXML literals to JavaFX GUI.
Author:
杨博 (Yang Bo) <[email protected]>
- Annotations
- @compileTimeOnly( ... )
- Note
The FXML support is still experimental. API or behavior of this annotation may change without bumping a majoy version number.
- See also
https://github.com/ThoughtWorksInc/Binding.scala/wiki/FXML for usage
Value Members
-
object
Binding extends WithTypeClass[Monad, Binding]
Author:
杨博 (Yang Bo) <[email protected]>
- object FutureBinding
- object JsPromiseBinding
-
object
Route
Author:
杨博 (Yang Bo) <[email protected]>
- object XmlExtractor
-
object
dom
Author:
杨博 (Yang Bo) <[email protected]>
- object fxml