API
useQueryStates
Bind a schema of keys to one writable object, with cross-field rules, written in one navigation.
Hover the name for its full signature.
import { useQueryStates } from '@chronicstone/vue-route-query'
Options
| Option | Type | Description |
|---|---|---|
schema | Record<string, codec | dynamicQueryState> | One entry per property of the value. |
prefix | string | Prepended to every key as prefix.key. |
urlKeys | { [property]?: string } | URL keys that differ from the property names. |
historyMode | 'push' | 'replace' | History mode for writes from this group. A codec's own historyMode wins for its key. |
rules | Record<string, rule> | Cross-field rules, keyed by name. |
Rules
| Field | Type | Description |
|---|---|---|
keys | (keyof schema)[] | The keys the rule reads. The rule is skipped while any of them is undefined. |
check | (values) => boolean | Gets the named keys, typed and defined. Return false to reject. |
reject | keys from keys | Keys that fall back to their defaults when check fails. Must be among keys. |
message | string | Shown in issues and in the development warning. |
Rules run in declaration order when the URL is read. Writes from your code are kept as they are.
Returns
WritableComputedRef<{ [K in keyof schema]: value of K }>. Assign a whole new object to write. Every key of the group goes to the URL in one navigation.