Binding

com.thoughtworks.binding.Binding
See theBinding companion object
trait Binding[+A] extends Watchable[A]

A data binding expression that represents a value that automatically recalculates when its dependencies change.

Attributes

Authors:

杨博 (Yang Bo) <[email protected]>

Example:

You may create a data binding expression via Binding { ??? } block annotation.

         val bindingInt: Binding[Int] = Binding { 100 }

A data binding expression may depend on other binding expressions via bind method:

         val bindingString: Binding[String] = Binding { bindingInt.bind.toString }
Companion:
object
Graph
Supertypes
trait Watchable[A]
class Object
trait Matchable
class Any
Known subtypes
class Constant[A]
class FlatMap[A, B]
class Map[A, B]
class Var[A]

Members list

Concise view

Value members

Concrete methods

final def flatMap[B](f: A => Binding[B]): Binding[B]
final def map[B](f: A => B): Binding[B]
final def unwatch(): Unit

Disable automatic recalculation.

Disable automatic recalculation.

Attributes

Note:

This method is recursive, which means that the dependencies of this Binding will be unwatched as well.

final def watch(): Unit

Enable automatic recalculation.

Enable automatic recalculation.

You may invoke this method more than once. Then, when you want to disable automatic recalculation, you must invoke unwatch same times as the number of calls to this method.

Attributes

Note:

This method is recursive, which means that the dependencies of this Binding will be watched as well.

Inherited methods

transparent inline def bind: A
Extension method from Binding

Returns the current value of this Binding and marks the current @dom method depend on this Binding.

Returns the current value of this Binding and marks the current @dom method depend on this Binding.

Each time the value changes, in the current @dom method, all code after the current bind expression will be re-evaluated if the current @dom method is watching. However, code in current @dom method and before the current bind expression will not be re-evaluated. The above rule is not applied to DOM nodes created by XHTML literal. A bind expression under a DOM node does not affect siblings and parents of that node.

Attributes

Note:

This method must be invoked inside a @dom method body or a Binding { ... } block..

Inherited from:
Companion