Documentation / @zerotal/flow / index / param
Function: param()
Call Signature
param(
value,context):void
Defined in: flow/src/decorators.ts:905
Fills a field from the matched route segment before onMount() runs — including a
route-model binding, so a page on /posts/:post
receives the loaded Post without querying for it.
Parameters
value
unknown
context
ClassFieldDecoratorContext
Returns
void
When configured, a field decorator; when used bare, nothing (applied directly).
Remarks
Usable bare as @param (the field's own name is the segment), as @param('slug') to read a
differently-named segment, or as @param(Post) to take whichever segment resolved to an
instance of that model — so the field never has to track what a route called it. One model
claims one segment name, so the token form is unambiguous for anything binding implicitly;
a route that hand-binds a second segment to the same model yields the leftmost.
Seeding happens once, on the initial GET — the only request that carries the URL's
segments. On subsequent WebSocket actions the value is restored from the snapshot instead
(a model through Flow's model synth), so pair it with @locked and the record is never
re-queried.
@param registers the binding only; combine it with @locked for server-owned data, or
@expose if the client may also write it. Applies to a field.
Example
class PostDetailPage extends Component {
@locked @param post!: Post; // /posts/:post -> the bound Post
@locked @param(Post) article!: Post; // whichever segment resolved to a Post
@locked @param("tab") activeTab = ""; // /posts/:post/:tab -> the raw segment
}
Call Signature
param(
source?):ParamDecorator
Defined in: flow/src/decorators.ts:906
Fills a field from the matched route segment before onMount() runs — including a
route-model binding, so a page on /posts/:post
receives the loaded Post without querying for it.
Parameters
source?
string | ParamModel
Returns
ParamDecorator
When configured, a field decorator; when used bare, nothing (applied directly).
Remarks
Usable bare as @param (the field's own name is the segment), as @param('slug') to read a
differently-named segment, or as @param(Post) to take whichever segment resolved to an
instance of that model — so the field never has to track what a route called it. One model
claims one segment name, so the token form is unambiguous for anything binding implicitly;
a route that hand-binds a second segment to the same model yields the leftmost.
Seeding happens once, on the initial GET — the only request that carries the URL's
segments. On subsequent WebSocket actions the value is restored from the snapshot instead
(a model through Flow's model synth), so pair it with @locked and the record is never
re-queried.
@param registers the binding only; combine it with @locked for server-owned data, or
@expose if the client may also write it. Applies to a field.
Example
class PostDetailPage extends Component {
@locked @param post!: Post; // /posts/:post -> the bound Post
@locked @param(Post) article!: Post; // whichever segment resolved to a Post
@locked @param("tab") activeTab = ""; // /posts/:post/:tab -> the raw segment
}