@jimka/typescript-ui / data / MemoryProxy
Class: MemoryProxy
Defined in: src/typescript/lib/data/proxy/MemoryProxy.ts:31
An in-memory proxy that stores data as a plain JavaScript array. All operations resolve synchronously via Promise.resolve.
Remarks
Because this proxy holds no external state, data is lost when the page is refreshed or the proxy instance is discarded. It is primarily intended for testing and for stores that manage transient, client-only data.
Extends
Constructors
new MemoryProxy()
new MemoryProxy(options: MemoryProxyOptions): MemoryProxyDefined in: src/typescript/lib/data/proxy/MemoryProxy.ts:40
Constructs a MemoryProxy, optionally pre-populated with an initial data array.
Parameters
options
MemoryProxyOptions = ...
Optional. Options object containing the initial data array.
Returns
Overrides
Methods
create()
create(record: ModelRecord): Promise<Record<string, any>>Defined in: src/typescript/lib/data/proxy/MemoryProxy.ts:73
Appends a copy of the record's data to the in-memory array.
Parameters
record
The new ModelRecord to store.
Returns
Promise<Record<string, any>>
A promise that resolves to the stored copy of the record's data.
Overrides
destroy()
destroy(record: ModelRecord): Promise<void>Defined in: src/typescript/lib/data/proxy/MemoryProxy.ts:119
Removes the matching entry from the in-memory array by primary key.
Parameters
record
The ModelRecord to remove.
Returns
Promise<void>
A promise that resolves when the removal is complete.
Remarks
If the model has no primary key or the record is not found, the array is left unchanged and the method still resolves successfully.
Overrides
getLastTotalCount()
getLastTotalCount(): undefined | numberDefined in: src/typescript/lib/data/proxy/Proxy.ts:84
Returns the total record count reported by the most recent paginated read.
Returns
undefined | number
The total count from the last paginated response, or undefined if the proxy does not support pagination or no paginated read has occurred.
Remarks
Default implementation returns undefined. Pagination-aware proxies (such as AjaxProxy) override this to return the total value parsed from the server envelope.
Inherited from
read()
read(_params?: ReadParams): Promise<any[]>Defined in: src/typescript/lib/data/proxy/MemoryProxy.ts:62
Returns a copy of the in-memory data array.
Parameters
_params?
Optional. Pagination parameters; ignored by this proxy.
Returns
Promise<any[]>
A promise that resolves to a shallow copy of the current data array.
Overrides
setData()
setData(data: any[]): voidDefined in: src/typescript/lib/data/proxy/MemoryProxy.ts:51
Replaces the in-memory data array used by this proxy.
Parameters
data
any[]
The new data array; a shallow copy is stored internally.
Returns
void
update()
update(record: ModelRecord): Promise<Record<string, any>>Defined in: src/typescript/lib/data/proxy/MemoryProxy.ts:92
Updates the matching entry in the in-memory array by primary key.
Parameters
record
The dirty ModelRecord whose data should replace the existing entry.
Returns
Promise<Record<string, any>>
A promise that resolves to the updated copy of the record's data.
Remarks
If the model has no primary key or the record is not found in the array, the array is left unchanged and the method still resolves successfully.