Mirror / Mirrored state

Why keeping the Model authoritative prevents drift

  • Defaults stay out of the URL: App.initial defines every field's default, so any field matching its initial value is removed from the store. Pass keys: { page: { keep: true } } when a default value should stay visible in the URL.
  • No navigation loops: Each subscription tracks the encoded key string as its dependency. One Model change triggers at most one store write, and a popstate navigation reduces the URL back into the Model, produces the identical key string, and stops.
  • Automatic codecs: String, number, and boolean fields encode directly as readable query values, while complex fields use JSON unless you provide a custom keys: { tags: { codec } }.
  • Safe link building: Filters.href(model, { page: 2 }) computes a link from the live Model with only the target key changed, instead of concatenating query strings by hand.