Skip to content
ts
import { param } from '@trail-run/core/reactive/query-params';

Function: param()

ts
function param(config): PropertyDecorator;

Defined in: src/reactive/query-params.ts:125

Decorator which marks a field as a query parameter.

This decorator only stores metadata - it does not change the property behavior. The field will operate as a normal

Parameters

config

ParamConfig

Configuration for URL serialization/deserialization

Returns

PropertyDecorator

Field

until a QPRoute consumes it.

The provided ParamConfig will be used by QPRoute to:

  • Serialize values for the URL
  • Deserialize values from the URL
  • Compare URL and local values
  • Determine when to include/exclude params from the URL

Example

ts
@SessionResource('map-state')
class MapState {
  @param({
    serialize: (value: boolean) => value ? '1' : null,
    deserialize: (urlValue: string) => urlValue === '1',
    compare: (urlValue: string, localValue: boolean) => (urlValue === '1') === localValue,
    isDefault: (urlValue: string) => urlValue !== '1',
  })
  @field
  active: boolean = false;
}

Released under the MIT License.