Packages

package bindable

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. bindable
  2. ToBindableSeqOps
  3. ToBindableOps
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Bindable[-From] extends Serializable

    A dependent type class that witnesses a type that can be converted to a Binding[Value].

    A dependent type class that witnesses a type that can be converted to a Binding[Value].

    Example:
    1. The implicit conversion to Binding can be enabled by the following import statement:

      import com.thoughtworks.binding.bindable._

      Then, a @dom XHTML template can establish data-binding on any parameter as long as a Bindable type class for the parameter type is available.

      @dom
      def mySection[A: Bindable.Lt[?, String]](parameter: A) = {
        <img class={parameter.bind}/>
      }

      Note that the ? syntax requires the Scala plug-in kind-projector, which can be enabled by adding the following setting into your build.sbt:

      addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
      
      The mySection method accepts any parameter who is a subtype of Binding[String].

      import com.thoughtworks.binding._, Binding._
      Binding {
        mySection(Binding("my-class-1")).bind.className should be("my-class-1")
        mySection(Constant("my-class-2")).bind.className should be("my-class-2")
      }.watch()

      And the mySection method also accepts String parameter.

      Binding {
        mySection("my-class-3").bind.className should be("my-class-3")
      }.watch()

      mySection should not accept irrelevant parameter types like scala.List or scala.Int.

      "mySection(List.empty)" shouldNot compile
      "mySection(42)" shouldNot compile
  2. trait BindableSeq[-From] extends Serializable

    A dependent type class that witnesses a type that can be converted to a BindingSeq[Value].

    A dependent type class that witnesses a type that can be converted to a BindingSeq[Value].

    Example:
    1. The bindSeq can be enabled by the following import statement:

      import com.thoughtworks.binding.bindable._

      Then, a @dom XHTML template can establish data-binding on any parameter as long as a BindableSeq type class for the parameter type is available.

      import org.scalajs.dom.raw._
      
      @dom
      def mySection[A: BindableSeq.Lt[?, Node]](parameter: A) = {
        <section>{parameter.bindSeq}</section>
      }

      Note that the ? syntax requires the Scala plug-in kind-projector, which can be enabled by adding the following setting into your build.sbt:

      addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
      
      The mySection method accepts any parameter who is a subtype of Binding[Node] or Binding[BindingSeq[Node]].

      import com.thoughtworks.binding._, Binding._
      @dom def myButton: Binding[HTMLButtonElement] = <button type="button">My Button 0</button>
      @dom def myButtons: Binding[BindingSeq[Node]] = <button type="button">My Button 1</button><button type="button">My Button 2</button>
      Binding {
        mySection(myButton).bind.innerHTML should be("")
        mySection(myButtons).bind.innerHTML should be("")
      }.watch()

      And the mySection method also accepts Node, BindingSeq[Node], List[Node], Array[Node], js.Array[Node], or Binding[js.Array[Node]] parameter.

      import scala.scalajs.js
      @dom def test = {
        mySection(<button type="button">My Button 3</button>).bind.innerHTML should be("")
        mySection(<button type="button">My Button 4</button><button type="button">My Button 5</button>).bind.innerHTML should be(
          ""
        )
        mySection(List(<button type="button">My Button 6</button>, <button type="button">My Button 7</button>)).bind.innerHTML should be("")
        mySection(Array(<button type="button">My Button 8</button>, <button type="button">My Button 9</button>)).bind.innerHTML should be("")
        mySection(js.Array(<button type="button">My Button 10</button>, <button type="button">My Button 11</button>)).bind.innerHTML should be("")
        mySection(Constant(js.Array(<button type="button">My Button 12</button>, <button type="button">My Button 13</button>))).bind.innerHTML should be("")
      }
      
      test.watch()

      mySection should not accept irrelevant parameter types like scala.collection.immutable.Set or scala.Int.

      "mySection(Set.empty)" shouldNot compile
      "mySection(42)" shouldNot compile

Value Members

  1. implicit def bindableToBinding[From, Value](from: From)(implicit bindable: Lt[From, Value]): Binding[Value]
  2. implicit def toBindableOps[From](target: From)(implicit tc: Bindable[From]): Ops[From] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[From]{type Value = tc.Value} }
    Definition Classes
    ToBindableOps
    Annotations
    @SuppressWarnings()
  3. implicit def toBindableSeqOps[From](target: From)(implicit tc: BindableSeq[From]): Ops[From] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[From]{type Value = tc.Value} }
    Definition Classes
    ToBindableSeqOps
    Annotations
    @SuppressWarnings()
  4. object Bindable extends LowPriorityBindable0 with Serializable
  5. object BindableSeq extends LowPriorityJsBindableSeq0 with Serializable

Inherited from ToBindableSeqOps

Inherited from ToBindableOps

Inherited from AnyRef

Inherited from Any

Ungrouped