-
Notifications
You must be signed in to change notification settings - Fork 2
Workspace
This is a class that you will use to manipulate and store non-array data such a forms, complex states, ui states etc.
actionCreators: WorkspaceActionCreators<T>
- this is all redux action creators that workspace uses. It will help you in cases when you need to perform actions manually and explicit. In 99.99% cases you won't need it.
- Get methods
- Dispatch methods
- Mixed methods (Get + Dispatch methods combinations)
get$(): Observable<T | undefined>
It returns observable that will listen to the actual workspace value.
getLoadingState$(isAsap? boolean): Observable<LoadingState | undefined>
It returns observable that will listen to the full workspace loading state. LoadingState for workspace is changed for every action that runs remote action. isAsap
flag will set scheduler for this observable to asapScheduler.
change: (
patch: PatchRequest<T>,
label: string,
options?: ChangeOptions,
) => WorkspaceActions
This method will dispatch an action that will change workspace value using patch
.
patch: PatchRequest<T>
- [required] a patch to apply. It can be either deep partial object of T
, or a function that will accept previous value from store and return a deep partial object of T.
options: ChangeOptions
- [optional]:
-
merge: boolean
- [optional] [default: true] whether to merge patch with exist workspace value or to replace it with patch. Merge is perfromed by merge util.
setLoadingState(
state: LoadingState,
key?: string,
options?: LoadingStateSetOptions,
): WorkspaceActions;
This will dispatch an action and store new loading state
.
state: LoadingState
- [required] loading state to store
key: string
- [optional] a key to set loading state as child loading state
options: LoadingStateSetOptions
- [optional] - no options is now available
batch(
actions: WorkspaceActions[],
): WorkspaceActions;
This method allows you to dispatch several actions manually and explicit.
changeRemote$(
patch: PatchRequest<T>,
dataSource$: Observable<DeepPartial<T> | undefined>,
label: string,
options?: ChangeOptions,
): Observable<DeepPartial<T>>;
This method will subscribe to dataSource$
and apply patch using change method. It will also affect loading state using setLoadingState. This method returns cold observable.
patch: PatchRequest<T>
- [required] the patch to apply. It can be either deep partial object of T
, or a function that will accept previous value from store and return a deep partial object of T.
This patch will be used if options.optimistic
equals true
. In basic cases you have to pass undefined
and the patch will be recieved from dataSource$
dataSource$: Observable<T>
- [required] the source of patch.
label: string
- [required] the label to assotiate the action in Redux Dev Tools.
options: ChangeOptions
- [optional]:
-
merge: boolean
- [optional] [default: true] whether to merge patch with exist entity or to replace it with patch. whether to merge entity isntances if there is instances with the same id. Merge is perfromed by merge util. -
ifNotExist: boolean
- [optional] [default: false] to create an entity if no entity with givenid
exists -
optimistic: boolean
- [optional] [default: false] whether to use optimistic strategy. More detailed here