From 7e6f3aa1679eadf2e70820f7bcca5618edef8371 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sat, 6 Nov 2021 01:19:55 -0700 Subject: [PATCH] Support converting a Watchable to a BindingSeq --- .../thoughtworks/binding/bindable/package.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala b/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala index 281ed73..7e904cb 100644 --- a/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala +++ b/shared/src/main/scala/com/thoughtworks/binding/bindable/package.scala @@ -99,7 +99,7 @@ package bindable { def toBinding(from: From): Binding[Value] } - private[bindable] trait LowPriorityBindableSeq2 { + private[bindable] trait LowPriorityBindableSeq3 { @deprecated("Potential naming conflict with `Bindable.constantBindable`.", "1.0.2") private[bindable] def constantBindable[Value] = constantsBindableSeq[Value] @@ -109,6 +109,21 @@ package bindable { } } + private[bindable] trait LowPriorityBindableSeq2 extends LowPriorityBindableSeq3 { + implicit def watchableBindableSeq[Value0]: BindableSeq.Aux[Watchable[Value0], Value0] = + new BindableSeq[Watchable[Value0]] { + type Value = Value0 + def toBindingSeq(from: Watchable[Value]): BindingSeq[Value] = { + from match { + case binding: Binding[Value] => + SingletonBindingSeq(binding) + case bindingSeq: BindingSeq[Value] => + bindingSeq + } + } + } + } + private[bindable] trait LowPriorityBindableSeq1 extends LowPriorityJsBindableSeq2 { implicit def bindingBindableSeq[Value0]: BindableSeq.Aux[Binding[Value0], Value0] = new BindableSeq[Binding[Value0]] {