Documentation / @warp-drive/core / reactive / LegacyLiveArray
Interface: LegacyLiveArray<T>
Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:74
Legacy
LiveArrays contain all the known records for a given ResourceType
.
Basic Example
For instance, if an application were to have a 'user'
type:
const usersLiveArray = store.peekAll('user');
LiveArrays are Arrays
LiveArrays have all array APIs, and will report true
for both liveArray instanceof Array
and Array.isArray(liveArray)
Reactive
The array is "live" as it will reactively update any time new users are added to the store's cache.
There is only one LiveArray instance per ResourceType, and it can be accessed either via Store.peekAll or Store.findAll
const users = await store.findAll('user');
const peekedUsers = store.peekAll('user');
peekedUsers === users; // true
New Records
Records in the "new"
state (created locally on the client but not yet saved) appear in LiveArrays if they are in LegacyMode.
PolarisMode records in the "new"
state do not appear in LiveArrays.
Polymorphism
LiveArrays are not polymorphic. If your application has an abstract type "car" with concrete types "ferrari" and "bmw", then "ferrari" and "bmw" will have populated LiveArrays, but the LiveArray for "car" would be empty.
we recommend againt using LiveArrays. Use Store.request instead
Extends
LegacyArray
<T
>
Extended by
Type Parameters
T
T
= unknown
Indexable
[key: number]: T
Methods
save()
save(this): Promise<LegacyArray<T>>;
Defined in: core/src/store/-private/record-arrays/-utils.ts:66
Saves all of the records in the RecordArray
.
Example
let messages = store.peekAll('message');
messages.forEach(function(message) {
message.hasBeenSeen = true;
});
messages.save();
Parameters
this
LegacyArray
<T
>
Returns
Promise
<LegacyArray
<T
>>
Inherited from
LegacyArray.save
update()
update(this): Promise<LegacyArray<T>>;
Defined in: core/src/store/-private/record-arrays/-utils.ts:49
Used to get the latest version of all of the records in this array from the adapter.
Example
let people = store.peekAll('person');
people.isUpdating; // false
people.update().then(function() {
people.isUpdating; // false
});
people.isUpdating; // true
Parameters
this
LegacyArray
<T
>
Returns
Promise
<LegacyArray
<T
>>
Inherited from
LegacyArray.update
Properties
isLoaded
isLoaded: boolean;
Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:75
isUpdating
isUpdating: boolean;
Defined in: core/src/store/-private/record-arrays/-utils.ts:26
The flag to signal a RecordArray
is currently loading data. Example
let people = store.peekAll('person');
people.isUpdating; // false
people.update();
people.isUpdating; // true
Inherited from
LegacyArray.isUpdating
modelName
modelName: TypeFromInstanceOrString<T>;
Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:80