Skip to content

@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 ParameterDefault type
Tunknown

Constructors

Constructor

ts
new Ref<T>(expr): Ref<T>;

Defined in: rx/collection.ts:32

Parameters

ParameterType
exprstring

Returns

Ref<T>

Properties

expr

ts
readonly expr: string;

Defined in: rx/collection.ts:26


type

ts
readonly type: "ref";

Defined in: rx/collection.ts:27

Methods

toRx()

ts
toRx(): Rx;

Defined in: rx/collection.ts:37

Rx expression for use in component props

Returns

Rx


toString()

ts
toString(): string;

Defined in: rx/collection.ts:41

Returns

string


toJSON()

ts
toJSON(): string;

Defined in: rx/collection.ts:45

Returns

string


dot()

Call Signature

ts
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
ParameterType
fieldK
Returns

Ref<T[K]>

Call Signature

ts
dot(field): Ref;

Defined in: rx/collection.ts:57

Untyped escape hatch for dynamic/computed field names.

Parameters
ParameterType
fieldstring
Returns

Ref


formatted()

ts
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

ParameterType
fieldstring | keyof T & string
pipeNamestring
...argsunknown[]

Returns

Rx


pipe()

ts
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

ParameterType
namestring
...argsunknown[]

Returns

Rx

Released under the MIT License.