11package com .thoughtworks .binding
22
3+ import com .thoughtworks .binding ._
34import com .thoughtworks .binding .Binding ._
5+ import com .thoughtworks .enableIf
46import simulacrum ._
57import scala .language .implicitConversions
68
@@ -47,6 +49,9 @@ package bindable {
4749 import Jvm ._
4850 import Js ._
4951
52+ import scala .concurrent .{ExecutionContext , Future }
53+ import scala .util .Try
54+
5055 private [bindable] trait LowPriorityBindable0 {
5156
5257 implicit def constantBindable [Value0 ]: Bindable .Aux [Value0 , Value0 ] = new Bindable [Value0 ] {
@@ -69,6 +74,21 @@ package bindable {
6974 def toBinding (from : Binding [Value0 ]): Binding [Value ] = from
7075 }
7176
77+ implicit def futureBindable [Value0 ](
78+ implicit executionContext : ExecutionContext ): Bindable .Aux [Future [Value0 ], Option [Try [Value0 ]]] =
79+ new Bindable [Future [Value0 ]] {
80+ type Value = Option [Try [Value0 ]]
81+ def toBinding (from : Future [Value0 ]): Binding [Value ] = FutureBinding (from)
82+ }
83+
84+ @ enableIf(c => c.compilerSettings.exists(_.matches(""" ^-Xplugin:.*scalajs-compiler_[0-9\.\-]*\.jar$""" )))
85+ implicit def thenableBindable [Value0 ]
86+ : Bindable .Aux [scala.scalajs.js.Thenable [Value0 ], Option [Either [Any , Value0 ]]] =
87+ new Bindable [scala.scalajs.js.Thenable [Value0 ]] {
88+ type Value = Option [Either [Any , Value0 ]]
89+ def toBinding (from : scala.scalajs.js.Thenable [Value0 ]): Binding [Value ] = JsPromiseBinding (from)
90+ }
91+
7292 }
7393
7494 /** A dependent type class that witnesses a type that can be converted to a `Binding[Value]`.
0 commit comments