These are chat archives for ThoughtWorksInc/Binding.scala

16th
Jan 2018
Mustafa Kuscu
@mcku
Jan 16 2018 12:39
Hi @Atry, i have started using your library. I think some helpers like this may be useful for beginners. I am kind of observing that dealing with futures and bindings add up extra lines of code..
 // some helpers for binding.scala
  @dom def futureBindingToBinding[T](futureBinding: Binding[Option[Try[T]]], emptyVal: T): Binding[T] = futureBinding.bind
    .map((y:Try[T]) => y.get)
    .getOrElse(emptyVal)

  @dom def futureBindingToBindingSeq[T](futureBindingSeq: Binding[Option[Try[Seq[T]]]], emptyVal: Seq[T]): Binding[BindingSeq[T]] = {
    val tmpSeq: Seq[T] = futureBindingSeq.bind
      .map((y: Try[Seq[T]]) => y.get)
      .getOrElse(emptyVal)
    val x: BindingSeq[T] = Vars(tmpSeq: _*)
    x
  }
杨博 (Yang Bo)
@Atry
Jan 16 2018 14:19
You can create your own library of these helpers. People will use your library as long as they feel useful.