Skip to content

Commit 5bebe30

Browse files
committed
Support converting a Watchable to a BindingSeq
1 parent 73449c0 commit 5bebe30

File tree

1 file changed

+16
-1
lines changed
  • shared/src/main/scala/com/thoughtworks/binding/bindable

1 file changed

+16
-1
lines changed

shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ package bindable {
9999
def toBinding(from: From): Binding[Value]
100100
}
101101

102-
private[bindable] trait LowPriorityBindableSeq2 {
102+
private[bindable] trait LowPriorityBindableSeq3 {
103103
@deprecated("Potential naming conflict with `Bindable.constantBindable`.", "1.0.2")
104104
private[bindable] def constantBindable[Value] = constantsBindableSeq[Value]
105105

@@ -109,6 +109,21 @@ package bindable {
109109
}
110110
}
111111

112+
private[bindable] trait LowPriorityBindableSeq2 extends LowPriorityBindableSeq3 {
113+
implicit def watchableBindableSeq[Value0]: BindableSeq.Aux[Watchable[Value0], Value0] =
114+
new BindableSeq[Watchable[Value0]] {
115+
type Value = Value0
116+
def toBindingSeq(from: Watchable[Value]): BindingSeq[Value] = {
117+
from match {
118+
case binding: Binding[Value] =>
119+
SingletonBindingSeq(binding)
120+
case bindingSeq: BindingSeq[Value] =>
121+
bindingSeq
122+
}
123+
}
124+
}
125+
}
126+
112127
private[bindable] trait LowPriorityBindableSeq1 extends LowPriorityJsBindableSeq2 {
113128
implicit def bindingBindableSeq[Value0]: BindableSeq.Aux[Binding[Value0], Value0] =
114129
new BindableSeq[Binding[Value0]] {

0 commit comments

Comments
 (0)