Skip to content

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:

ts
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

ts
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

ts
[key: number]: T

Methods

save()

ts
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

js
let messages = store.peekAll('message');
messages.forEach(function(message) {
  message.hasBeenSeen = true;
});
messages.save();

Parameters

this

LegacyArray<T>

Returns

Promise<LegacyArray<T>>

Inherited from

ts
LegacyArray.save

update()

ts
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

javascript
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

ts
LegacyArray.update

Properties

isLoaded

ts
isLoaded: boolean;

Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:75


isUpdating

ts
isUpdating: boolean;

Defined in: core/src/store/-private/record-arrays/-utils.ts:26

The flag to signal a RecordArray is currently loading data. Example

javascript
let people = store.peekAll('person');
people.isUpdating; // false
people.update();
people.isUpdating; // true

Inherited from

ts
LegacyArray.isUpdating

modelName

ts
modelName: TypeFromInstanceOrString<T>;

Defined in: core/src/store/-private/record-arrays/legacy-live-array.ts:80

Released under the MIT License.