Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.97 KB

0.10.1.md

File metadata and controls

52 lines (38 loc) · 1.97 KB

0.10.1 (commit log)

  • Added conversions between Callback and Future.

    Input Method Output
    CallbackTo[A] cb.toFuture Future[A]
    CallbackTo[Future[A]] cb.toFlatFuture Future[A]
    => Future[A] CallbackTo(f) CallbackTo[Future[A]]
    => Future[CallbackTo[A]] CallbackTo.future(f) CallbackTo[Future[A]]
    => Future[CallbackTo[A]] Callback.future(f) Callback

    If you're looking for ways to block (eg. turning a Callback[Future[A]] into a Callback[A]), it is not supported by Scala.JS (See #1996).

    NOTE: It's important that when going from Future to Callback, you're aware of when the Future is instantiated.

    def queryServer: Future[Data] = ???
    
    def updateComponent: Future[Callback] =
      queryServer.map($ setState _)
    
    // This is GOOD because the callback wraps the updateComponent *function*, not an instance.
    Callback.future(updateComponent)
    
    // This is BAD because the callback wraps a single instance of updateComponent.
    // 1) The server will be contacted immediately instead of when the callback executes.
    // 2) If the callback is executed more than once, the future and old result will be reused.
    val f = updateComponent
    Callback.future(f)
    
    // This is GOOD too because the future is created inside the callback.
    Callback.future {
      val f = updateComponent
      f.onComplete(???)
      f
    }
  • Add CallbackOption.{pass,fail}.

  • Add Callback{,Option}.voidExplicit.

  • Add React.Children.toArray.

  • Upgrade React to 0.14.1. Adds new attributes:

    • default
    • kind
    • srcLang
  • Upgrade Scala.JS to 0.6.5.