@maxhealth.tech/prefab / rx / Collection
Class: Collection<T>
Defined in: rx/collection.ts:87
A named keyed array. Serializes rows into state and provides typed lookup helpers that compile to pipe expressions.
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends Record<string, unknown> | Record<string, unknown> |
Constructors
Constructor
new Collection<T>(
stateKey,
rows,
keyField): Collection<T>;Defined in: rx/collection.ts:92
Parameters
| Parameter | Type |
|---|---|
stateKey | string |
rows | T[] |
keyField | string |
Returns
Collection<T>
Properties
stateKey
readonly stateKey: string;Defined in: rx/collection.ts:88
keyField
readonly keyField: string;Defined in: rx/collection.ts:89
rows
readonly rows: T[];Defined in: rx/collection.ts:90
Accessors
length
Get Signature
get length(): number;Defined in: rx/collection.ts:113
Number of rows.
Returns
number
Methods
firstKey()
firstKey(): string | null;Defined in: rx/collection.ts:99
Key of the first row, or null if empty.
Returns
string | null
lastKey()
lastKey(): string | null;Defined in: rx/collection.ts:106
Key of the last row, or null if empty.
Returns
string | null
by()
by<K>(key): Ref<T>;Defined in: rx/collection.ts:121
Create a Ref that lazily resolves a row by signal key. Compiles to: {{ stateKey | find:'keyField',signal.key }}
Type Parameters
| Type Parameter |
|---|
K extends SignalValue |
Parameters
| Parameter | Type |
|---|---|
key | Signal<K> |
Returns
Ref<T>
toRx()
toRx(): Rx;Defined in: rx/collection.ts:126
Rx expression referencing the full array: {{ stateKey }}
Returns
toString()
toString(): string;Defined in: rx/collection.ts:130
Returns
string
toJSON()
toJSON(): string;Defined in: rx/collection.ts:134
Returns
string
toState()
toState(): Record<string, T[]>;Defined in: rx/collection.ts:139
State entry for PrefabApp: { stateKey: rows }
Returns
Record<string, T[]>