Skip to content

Documentation / @imvu/client / Collection

Class: Collection<T> ​

Defined in: packages/client/src/collections/Collection.ts:36

A sparse URL-backed collection with fresh page reads and optional realtime invalidation.

Extends ​

Type Parameters ​

Type ParameterDefault type
TAPIResource

Implements ​

  • AsyncIterable<T>

Constructors ​

Constructor ​

ts
new Collection<T>(
   client, 
   url, 
   itemType?, 
   options?
): Collection<T>;

Defined in: packages/client/src/collections/Collection.ts:40

Parameters ​

ParameterTypeDescription
clientClient-
urlstring-
itemType?Constructor<Resource<APIRelations, APIUpdateTarget>>The model used to hydrate each normalized item, if any.
options?CollectionOptions-

Returns ​

Collection<T>

Overrides ​

RemoteDocument.constructor

Properties ​

_url ​

ts
protected _url: string = '';

Defined in: packages/client/src/resources/RemoteDocument.ts:13

Inherited from ​

ProductSaleEvent._url


client ​

ts
protected readonly client: Client;

Defined in: packages/client/src/resources/RemoteDocument.ts:16

Inherited from ​

ProductSaleEvent.client


itemType? ​

ts
readonly itemType?: Constructor<Resource<APIRelations, APIUpdateTarget>>;

Defined in: packages/client/src/collections/Collection.ts:44

Internal

The model used to hydrate each normalized item, if any.


options ​

ts
readonly options: CollectionOptions = {};

Defined in: packages/client/src/collections/Collection.ts:46

Internal


revision ​

ts
revision: number = 0;

Defined in: packages/client/src/resources/RemoteDocument.ts:8

Inherited from ​

RemoteDocument.revision


stale ​

ts
stale: boolean = false;

Defined in: packages/client/src/resources/RemoteDocument.ts:9

Inherited from ​

ProductSaleEvent.stale


totalCount? ​

ts
totalCount?: number;

Defined in: packages/client/src/collections/Collection.ts:38

Total reported by the most recent page/count response.


updateTarget ​

ts
updateTarget: 
  | APIUpdateTarget
  | null
  | undefined;

Defined in: packages/client/src/resources/RemoteDocument.ts:11

Undefined until metadata is loaded; null means the API explicitly provides no update target.

Inherited from ​

ProductSaleEvent.updateTarget

Accessors ​

url ​

Get Signature ​

ts
get url(): string;

Defined in: packages/client/src/resources/RemoteDocument.ts:28

Canonical REST URL and cache identity for this document.

Returns ​

string

Inherited from ​

RemoteDocument.url


watchability ​

Get Signature ​

ts
get watchability(): "unknown" | "supported" | "unsupported";

Defined in: packages/client/src/collections/Collection.ts:51

Returns ​

"unknown" | "supported" | "unsupported"

Methods ​

_applyRemoteMetadata() ​

ts
_applyRemoteMetadata(url, updateTarget): void;

Defined in: packages/client/src/resources/RemoteDocument.ts:33

Internal

Apply address/update metadata from an authoritative REST response.

Parameters ​

ParameterType
urlstring
updateTargetAPIUpdateTarget | null

Returns ​

void

Inherited from ​

RemoteDocument._applyRemoteMetadata


_invalidate() ​

ts
_invalidate(): void;

Defined in: packages/client/src/resources/RemoteDocument.ts:40

Internal

Mark this document stale after an IMQ invalidation.

Returns ​

void

Inherited from ​

RemoteDocument._invalidate


[asyncIterator]() ​

ts
[asyncIterator](): AsyncIterableIterator<T>;

Defined in: packages/client/src/collections/Collection.ts:67

Returns ​

AsyncIterableIterator<T>

Implementation of ​

AsyncIterable.[asyncIterator]


count() ​

ts
count(): Promise<number>;

Defined in: packages/client/src/collections/Collection.ts:56

Returns ​

Promise<number>


page() ​

ts
page(__namedParameters?): Promise<readonly T[]>;

Defined in: packages/client/src/collections/Collection.ts:63

Fetch a fresh range of items. Collection membership is intentionally not cached.

Parameters ​

ParameterType
__namedParameters?PageOptions

Returns ​

Promise<readonly T[]>


watch() ​

ts
watch(): Promise<DocumentWatch<Collection<T>>>;

Defined in: packages/client/src/collections/Collection.ts:80

Observe explicit IMQ invalidations for this document.

Returns ​

Promise<DocumentWatch<Collection<T>>>

Overrides ​

RemoteDocument.watch

Released under the MIT License.