-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathentity-action.ts
45 lines (38 loc) · 1.45 KB
/
entity-action.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Injectable } from '@angular/core';
import { Action } from '@ngrx/store';
import { EntityOp } from './entity-op';
import { MergeStrategy } from './merge-strategy';
/** Action concerning an entity collection. */
export interface EntityAction<P = any> extends Action {
readonly type: string;
readonly payload: EntityActionPayload<P>;
}
/** Options of an EntityAction */
export interface EntityActionOptions {
/** Correlate related EntityActions, particularly related saves. Must be serializable. */
readonly correlationId?: any;
/** True if should perform action optimistically (before server responds) */
readonly isOptimistic?: boolean;
readonly mergeStrategy?: MergeStrategy;
/** The tag to use in the action's type. The entityName if no tag specified. */
readonly tag?: string;
// Mutable actions are BAD.
// Unfortunately, these mutations are the only way to stop @ngrx/effects
// from processing these actions.
/**
* The action was determined (usually by a reducer) to be in error.
* Downstream effects should not process but rather treat it as an error.
*/
error?: Error;
/**
* Downstream effects should skip processing this action but should return
* an innocuous Observable<Action> of success.
*/
skip?: boolean;
}
/** Payload of an EntityAction */
export interface EntityActionPayload<P = any> extends EntityActionOptions {
readonly entityName: string;
readonly entityOp: EntityOp;
readonly data?: P;
}