trait Bindable[-From] extends Serializable
A dependent type class that witnesses a type that can be converted to a Binding[Value]
.
- Source
- package.scala
The implicit conversion to
Binding
can be enabled by the followingimport
statement:import com.thoughtworks.binding.bindable._
Then, a
@dom
XHTML template can establish data-binding on anyparameter
as long as a Bindable type class for theparameter
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 yourbuild.sbt
:addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3")
ThemySection
method accepts any parameter who is a subtype ofBinding[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
Example:
Linear Supertypes
Type Hierarchy
Ordering
- Alphabetic
- By Inheritance
Inherited
- Bindable
- Serializable
- Serializable
- Any
Implicitly
- by bindableToBinding
- by toBindableSeqOps
- by toBindableOps
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
Visibility
- Public
- All
Type Members
- abstract type Value
Abstract Value Members
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def +(other: String): String
- def ->[B](y: B): (Bindable[From], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final macro
def
bind: Value
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Binding[Value] performed by method bindableToBinding in com.thoughtworks.binding.bindable. This conversion will take place only if an implicit value of type Lt[Bindable[From], Value] is in scope.
- Definition Classes
- Binding
-
def
bindSeq: BindingSeq[BindableSeq.Value]
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableSeqOps in com.thoughtworks.binding.bindable.BindableSeq.ToBindableSeqOps. This conversion will take place only if an implicit value of type BindableSeq[Bindable[From]] is in scope.
- Definition Classes
- Ops
- def ensuring(cond: (Bindable[From]) ⇒ Boolean, msg: ⇒ Any): Bindable[From]
- def ensuring(cond: (Bindable[From]) ⇒ Boolean): Bindable[From]
- def ensuring(cond: Boolean, msg: ⇒ Any): Bindable[From]
- def ensuring(cond: Boolean): Bindable[From]
-
def
equals(arg0: Any): Boolean
- Definition Classes
- Any
- def formatted(fmtstr: String): String
-
def
hashCode(): Int
- Definition Classes
- Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
toBindingSeq: BindingSeq[BindableSeq.Value]
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableSeqOps in com.thoughtworks.binding.bindable.BindableSeq.ToBindableSeqOps. This conversion will take place only if an implicit value of type BindableSeq[Bindable[From]] is in scope.
- Definition Classes
- Ops
-
def
toString(): String
- Definition Classes
- Any
-
final
def
unwatch(): Unit
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Binding[Value] performed by method bindableToBinding in com.thoughtworks.binding.bindable. This conversion will take place only if an implicit value of type Lt[Bindable[From], Value] is in scope.
- Definition Classes
- Binding
- Annotations
- @inline()
-
final
def
watch(): Unit
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Binding[Value] performed by method bindableToBinding in com.thoughtworks.binding.bindable. This conversion will take place only if an implicit value of type Lt[Bindable[From], Value] is in scope.
- Definition Classes
- Binding
- Annotations
- @inline()
- def →[B](y: B): (Bindable[From], B)
Shadowed Implicit Value Members
-
def
self: Bindable[From]
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableSeqOps in com.thoughtworks.binding.bindable.BindableSeq.ToBindableSeqOps. This conversion will take place only if an implicit value of type BindableSeq[Bindable[From]] is in scope.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(bindable: Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} }).self
- Definition Classes
- Ops
-
def
self: Bindable[From]
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableOps in com.thoughtworks.binding.bindable.Bindable.ToBindableOps. This conversion will take place only if an implicit value of type Bindable[Bindable[From]] is in scope.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(bindable: Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} }).self
- Definition Classes
- Ops
-
def
toBinding: Binding[Value]
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableOps in com.thoughtworks.binding.bindable.Bindable.ToBindableOps. This conversion will take place only if an implicit value of type Bindable[Bindable[From]] is in scope.
- Shadowing
- This implicitly inherited member is shadowed by one or more members in this class.
To access this member you can use a type ascription:(bindable: Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} }).toBinding
- Definition Classes
- Ops
-
val
typeClassInstance: BindableSeq[Bindable[From]] { type Value = tc.Value }
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableSeqOps in com.thoughtworks.binding.bindable.BindableSeq.ToBindableSeqOps. This conversion will take place only if an implicit value of type BindableSeq[Bindable[From]] is in scope.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(bindable: Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.BindableSeq[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} }).typeClassInstance
- Definition Classes
- Ops
-
val
typeClassInstance: Bindable[Bindable[From]] { type Value = tc.Value }
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} } performed by method toBindableOps in com.thoughtworks.binding.bindable.Bindable.ToBindableOps. This conversion will take place only if an implicit value of type Bindable[Bindable[From]] is in scope.
- Shadowing
- This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
To access this member you can use a type ascription:(bindable: Ops[Bindable[From]] { type TypeClassType = com.thoughtworks.binding.bindable.Bindable[com.thoughtworks.binding.bindable.Bindable[From]]{type Value = tc.Value} }).typeClassInstance
- Definition Classes
- Ops
Deprecated Value Members
-
final macro
def
each: Value
- Implicit
- This member is added by an implicit conversion from Bindable[From] to Binding[Value] performed by method bindableToBinding in com.thoughtworks.binding.bindable. This conversion will take place only if an implicit value of type Lt[Bindable[From], Value] is in scope.
- Definition Classes
- Binding
- Annotations
- @deprecated
- Deprecated
(Since version 7.0.0) Use bind instead