Skip to content

NetWasm.UI 0.13.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 12:33
· 41 commits to main since this release

Added

  • TemplateRuntime.Rows, TemplateRow and Template.Listen: the rows of a keyed list as clones of
    one template, filled in by functions of the row that all rows share. See
    Rows. New TemplateListener op.
  • benchmarks/WasmBench: the keyed benchmark's C# side under Wasmtime, with times that repeat
    within about 1 % and exact allocation and batch sizes. See
    Benchmarks.

Changed

  • .nwui: the element of an @foreach body is compiled to rows of a template. A row is one
    clone and one object: its @expr text and bound attributes are one effect, and its @on…
    handlers for delegated events are registered once for the whole list. Creating rows takes about
    40 % less time on the C# side and sends about 40 % fewer bytes to the host. Templates need no
    change. Two things behave differently, see
    Rows of an @foreach:
    • A row whose key gets a different item in a new list (another object, or for a value type a
      value that is not equal) now shows that item in all of its content. A row that is only
      bindings and delegated handlers takes it in place; a row with a component, a block, @bind,
      @ref or other content that is applied once is built again for it. Before, the row kept the
      object it was created for. Keep the same object to keep the row.
    • The bindings of a row are evaluated together when something one of them reads changes. Only
      values that differ are written to the DOM.
  • Each and every other keyed list follow the same rule: a key that stays but gets a different
    item has its row disposed and rendered again for that item, in the same place. Before, the row
    kept the object it was created for. Lists without @key (the items are the keys) are not
    affected. See Conditionals and lists.
  • nwui.dom clones a template from its own inert document (a template with custom elements is
    still imported first) and finds a clone's text holes when they are first written to, instead of
    walking to every hole of every clone. Creating 10,000 rows spends about 8 ms less in the browser.
  • The keyed list reuses its keys and lookup tables from one list to the next, and it clears a list
    or swaps two rows without building them. Swapping two of 1,000 rows no longer allocates per row.
  • The benchmark runner warms up every case the way js-framework-benchmark does: create 10,000
    rows, append and select row were measured with less or no warm-up before.
  • The benchmark app is a .nwui template (benchmarks/NetWasmBench/BenchApp.nwui), so the
    benchmark measures what the template compiler emits.