Skip to content

Latest commit

 

History

History
83 lines (53 loc) · 2.82 KB

1.7.6.md

File metadata and controls

83 lines (53 loc) · 2.82 KB

1.7.6

Misc

  • Add .timeout(timeLimit) to AsyncCallback instances so that you can limit the amount of time to wait for the async procedure to complete.

    (Note: there's no built-in concept of cancellation here. If your procedure doesn't finish in time, this will return None when the time limit is reached however, the underlying procedure will become orphaned and continue to run in the background until complete.)

  • Add convenience methods CallbackTo for getting the current time:

    • now: CallbackTo[Instant]
    • currentTimeMillis: CallbackTo[Long]
    • nanoTime: CallbackTo[Long]
  • Add StateAccess.const(F[S]): StateAccess[F, S]

VDOM Refs

Add a new way of creating VDOM refs, called "untyped" refs.

There are two differences between the established ("typed") way, and this "untyped" way:

  1. It sacrifices some type-safety for flexibility. You can declare a ref to an <input> and apply it to a <select>. When the types don't line up, the ref simply rejects the dom it's passed. If you misuse this you won't get a runtime error, it will just be as though you didn't wire up the ref at all.

  2. Decoupling of control. With type-safe refs, you create the ref and apply it in the same class. With this new "untyped" ref, you can pass the ref around and have a completely different part of the code wire it up to vdom.

The untypedRef vdom attribute already existed but wasn't properly usable. It's now fixed and there are two ways of using it.

  1. The first is to just pass in a Dom => Unit function:
var refOrNull: html.Input = null

def render =
  <.input(^.untypedRef(refOrNull = _))
  1. The second is to create a Ref object and wire it up like a normal vdom attribute:

Usage:

val ref = Ref.toVdom[html.Input]

def render =
  <.input(^.untypedRef := ref)

Reusability

  • Add Reusability.MapImplicits which you can now import to enable implicit Reusability instances for Maps

  • Add an implicit Reusability[Range] instance

  • Add conversions between Option[Reusable[A]] <=> Reusable[Option[A]]

    • If you have a Option[Reusable[A]], call Reusable.sequenceOption
    • If you have a Reusable[Option[A]], call .sequenceOption
  • Add Reusable.emptyCallback: Reusable[Callback]

  • Prefix all members in Reusability.TemporalImplicitsWithoutTolerance by reusability

Testing

  • Add many more SimEvent.Keyboard definitions. All keys on a standard US keyboard are now covered.

  • Improve accuracy of pre-defined SimEvent.Keyboard values

  • SimEvent classes now have an assign(tgt: js.Dynamic, readOnlyProperties: Boolean = false): tgt.type method to populate a provided object-like value. (Useful for generating native events for testing.)

Upgraded dependencies

  • scalajs-dom 1.1.0
  • scala-collection-compat 2.2.0
  • Scala.JS 1.2.0