Learn / Wiring

Why use an assembly instead of hand-wiring?

With hand-wiring, forgetting a branch or omitting Data.subscriptions(active) compiles cleanly and fails silently at runtime. An assembly catches those omissions before shipping:

  • complete checks derivations: Passing a non-derived update, subscriptions, url, init, or managedResources fails to compile whenever an item in the list requires it.
  • Startup checks catch collisions: Two wirings claiming the same non-shared Message tag, sharing a key, or registering the same resource tag fail Page.assemble with both names in the error.
  • Exhaustive own catches a deleted wiring: When a wiring claims literal tags (such as Remote's Message tags), removing it from assemble(...) puts those tags back into own's input type, causing an exhaustive Match.valueTags or union match to fail compilation.

Note that deleting a wiring whose tags are all shared (such as a mirror), or using a non-exhaustive switch in own, leaves own's types satisfied. Test those behaviors with dispatch-level tests.

When to wire by hand instead

  • A single integration: If your app has one integration already covered by a dispatch test, hand-wiring is straightforward and remains fully supported.
  • Custom routers: wiring.url assumes a single URL Message; apps with a multi-route router keep their router and feed URL changes to mirrors directly.
  • Standalone scopes: Without a parent Model and Message union, there is nothing for Page.assemble to join.