import { DaffOperationEntityStateAdapterInterface } from '@daffodil/core/state'
An entity state adapter that takes care of managing contextual operation and error state for entities.
interface DaffOperationEntityStateAdapterInterface<T extends DaffIdentifiable = DaffIdentifiable> {
list<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entities: T[]
state: S
): S
preload<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
id: string
state: S
): S
load<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entity: T
state: S
): S
preadd<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entity: T
state: S
placeholderId?: string
): S
add<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entity: T
state: S
placeholderId?: string
): S
preupdate<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entity: Partial<T> & DaffIdentifiable
state: S
): S
update<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
entity: Partial<T> & DaffIdentifiable
state: S
): S
preremove<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
key: string
state: S
): S
remove<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
key: string
state: S
): S
operationFailed<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
key: string
errors: DaffStateError[]
state: S
): S
resetState<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(
key: string
state: S
): S
getInitialState<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(state?: S): S
getSelectors<TRootState>(selectState: (state: TRootState) => DaffOperationEntityState<T>): DaffOperationEntityStateSelectors<TRootState, T>
}
S
Stores a list of entities in state and resets them all to stable.
Parameter | entities: T[] |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Optimistically adds a placeholder entity into state if necessary and sets the entity to resolving.
Parameter | id: string |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Upserts the entity into state and resets operation state and errors.
Parameter | entity: T |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Adds a placeholder entity into state if placeholderId
is specified and sets state to adding.
Parameter | entity: T |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
Parameter | placeholderId: string |
---|---|
Description |
S
Adds the entity into state, sets operation state to added, and resets errors.
Parameter | entity: T |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
Parameter | placeholderId: string |
---|---|
Description |
S
Sets the entity's operation state to mutating.
Parameter | entity: Partial |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Upserts the entity into state, sets operation state to mutated, and resets errors.
Parameter | entity: Partial |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Sets the entity's operation state to deleting.
Parameter | key: string |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Removes the entity from state.
Parameter | key: string |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Resets the entity's operation state and stores errors on the entity.
Parameter | key: string |
---|---|
Description |
Parameter | errors: DaffStateError[] |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Resets the entity's operation state to stable.
Parameter | key: string |
---|---|
Description |
Parameter | state: S |
---|---|
Description |
S
Gets an empty entity state.
Parameter | state: S |
---|---|
Description |
DaffOperationEntityStateSelectors<TRootState, T>
Gets entity selectors.
Parameter | selectState: (state: TRootState) => DaffOperationEntityState |
---|---|
Description |