@o3r/core
Version:
Core of the Otter Framework
62 lines • 3.87 kB
TypeScript
import type { EntityAdapter, EntityState } from '@ngrx/entity';
import { AsyncStoreItem, EntityWithoutAsyncStoreItem } from './async.interfaces';
/** Adapter for Asynchronous Entity Store */
export interface EntityAsyncRequestAdapter<T extends AsyncStoreItem> extends EntityAdapter<T> {
/**
* Updates the AsyncStoreItem properties of each entity matching an id from the list of given ids, when a request has failed.
* @param state Actual state
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
* @param requestId Id of request which has failed
*/
failRequestMany<V extends EntityState<T> & AsyncStoreItem>(state: V, ids?: (string | number)[], requestId?: string): V;
/**
* Adds AsyncStoreItem property to the global store, or the entity if it already exists, when a request is triggered.
* @param state Actual state
* @param id Id of the entity to update
* @param requestId Id of the request which is triggered
*/
addRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, id: string | number | null | undefined, requestId: string): V;
/**
* Adds AsyncStoreItem properties for each entity matching the given ids, when a request is triggered
* @param state Actual state
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
* @param requestId Id of request which is triggered
*/
addRequestMany<V extends EntityState<T>>(state: V, ids: (string | number)[], requestId: string): V;
/**
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
* @param state Actual state
* @param entity Payload item;
* @param requestId Id of request which has resolved if any
*/
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<'id', string | number>, requestId?: string): V;
/**
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
* @param state Actual state
* @param entity Payload item;
* @param requestId Id of request which has resolved if any
* @param idProperty Property of the entity containing its unique identifier
*/
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem, W extends keyof T>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<W, string | number>, requestId?: string, idProperty?: W): V;
/**
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
* @param state Actual state
* @param entities Payload items;
* @param requestId Id of request which has resolved if any
*/
resolveRequestMany<V extends EntityState<T>>(state: V, entities: (Partial<T> & Record<'id', string | number>)[], requestId?: string): V;
/**
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
* @param state Actual state
* @param entities Payload items;
* @param requestId Id of request which has resolved if any
* @param idProperty Property of the entity containing its unique identifier
*/
resolveRequestMany<V extends EntityState<T>, W extends keyof T>(state: V, entities: (Partial<T> & Record<W, string | number>)[], requestId?: string, idProperty?: W): V;
}
/**
* Create an Asynchronous Request Entity Adapter
* @param adapter Entity Adapter
*/
export declare function createEntityAsyncRequestAdapter<T extends AsyncStoreItem>(adapter: EntityAdapter<T>): EntityAsyncRequestAdapter<T>;
//# sourceMappingURL=async-entity.adapter.d.ts.map