@maxhealth.tech/prefab / rx / Ref
Class: Ref<T>
Defined in: rx/collection.ts:25
A lazy, serializable reference to a row in a collection. The expression is evaluated at runtime by the renderer's pipe evaluator.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Constructors
Constructor
new Ref<T>(expr): Ref<T>;Defined in: rx/collection.ts:32
Parameters
| Parameter | Type |
|---|---|
expr | string |
Returns
Ref<T>
Properties
expr
readonly expr: string;Defined in: rx/collection.ts:26
type
readonly type: "ref";Defined in: rx/collection.ts:27
Methods
toRx()
toRx(): Rx;Defined in: rx/collection.ts:37
Rx expression for use in component props
Returns
toString()
toString(): string;Defined in: rx/collection.ts:41
Returns
string
toJSON()
toJSON(): string;Defined in: rx/collection.ts:45
Returns
string
dot()
Call Signature
dot<K>(field): Ref<T[K]>;Defined in: rx/collection.ts:55
Type-safe property access on the referenced row. Returns Ref<T[K]> so downstream type checking works.
ref.dot('name') → Ref<HumanName[]> with expr {{ ... | dot:'name' }}
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type |
|---|---|
field | K |
Returns
Ref<T[K]>
Call Signature
dot(field): Ref;Defined in: rx/collection.ts:57
Untyped escape hatch for dynamic/computed field names.
Parameters
| Parameter | Type |
|---|---|
field | string |
Returns
Ref
formatted()
formatted(
field,
pipeName, ...
args): Rx;Defined in: rx/collection.ts:69
Shorthand for .dot(field).pipe(pipeName, ...args). Compiles to {{ expr | dot:'field' | pipeName }}.
Use to format a nested field with any built-in or registered pipe: ref.formatted('total', 'currency') → {{ ... | dot:'total' | currency }}
Parameters
| Parameter | Type |
|---|---|
field | string | keyof T & string |
pipeName | string |
...args | unknown[] |
Returns
pipe()
pipe(name, ...args): Rx;Defined in: rx/collection.ts:78
Append a pipe filter to the ref expression. ref.pipe('upper') → {{ expr | upper }}ref.pipe('date', 'long') → {{ expr | date:'long' }}
Parameters
| Parameter | Type |
|---|---|
name | string |
...args | unknown[] |