ing
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export * from './meta-sensor-display-mapping.action';
|
||||
export * from './meta-sensor-display-mapping.effect';
|
||||
export * from './meta-sensor-display-mapping.reducer';
|
||||
export * from './meta-sensor-display-mapping.state';
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
|
||||
import { MetaSensorDisplayItem, MetaSensorItemKey } from '@overflow/commons-typescript/model/meta';
|
||||
|
||||
export enum ActionType {
|
||||
ReadAllMetaSensorItemKeyByDisplayItem = '[meta.meta-sensor-display-mapping] ReadAllMetaSensorItemKeyByDisplayItem',
|
||||
ReadAllMetaSensorItemKeyByDisplayItemSuccess = '[meta.meta-sensor-display-mapping] ReadAllMetaSensorItemKeyByDisplayItemSuccess',
|
||||
ReadAllMetaSensorItemKeyByDisplayItemFailure = '[meta.meta-sensor-display-mapping] ReadAllMetaSensorItemKeyByDisplayItemFailure',
|
||||
}
|
||||
|
||||
export class ReadAllMetaSensorItemKeyByDisplayItem implements Action {
|
||||
readonly type = ActionType.ReadAllMetaSensorItemKeyByDisplayItem;
|
||||
constructor(public payload: MetaSensorDisplayItem) {}
|
||||
}
|
||||
|
||||
export class ReadAllMetaSensorItemKeyByDisplayItemSuccess implements Action {
|
||||
readonly type = ActionType.ReadAllMetaSensorItemKeyByDisplayItemSuccess;
|
||||
|
||||
constructor(public payload: MetaSensorItemKey[]) {}
|
||||
}
|
||||
|
||||
export class ReadAllMetaSensorItemKeyByDisplayItemFailure implements Action {
|
||||
readonly type = ActionType.ReadAllMetaSensorItemKeyByDisplayItemFailure;
|
||||
|
||||
constructor(public payload: RPCClientError) {}
|
||||
}
|
||||
|
||||
export type Actions =
|
||||
| ReadAllMetaSensorItemKeyByDisplayItem
|
||||
| ReadAllMetaSensorItemKeyByDisplayItemSuccess
|
||||
| ReadAllMetaSensorItemKeyByDisplayItemFailure
|
||||
;
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { of } from 'rxjs';
|
||||
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
||||
|
||||
import { MetaSensorDisplayMappingService } from '../../../service/meta-sensor-display-mapping.service';
|
||||
|
||||
import {
|
||||
ReadAllMetaSensorItemKeyByDisplayItem,
|
||||
ReadAllMetaSensorItemKeyByDisplayItemSuccess,
|
||||
ReadAllMetaSensorItemKeyByDisplayItemFailure,
|
||||
ActionType,
|
||||
} from './meta-sensor-display-mapping.action';
|
||||
import { MetaSensorDisplayMapping, MetaSensorDisplayItem, MetaSensorItemKey } from '@overflow/commons-typescript/model/meta';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private metaSensorDisplayMappingService: MetaSensorDisplayMappingService,
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
readAllMetaSensorItemKeyByDisplayItem$ = this.actions$.pipe(
|
||||
ofType(ActionType.ReadAllMetaSensorItemKeyByDisplayItem),
|
||||
map((action: ReadAllMetaSensorItemKeyByDisplayItem) => action.payload),
|
||||
exhaustMap((metaSensorDisplayItem: MetaSensorDisplayItem) =>
|
||||
this.metaSensorDisplayMappingService
|
||||
.readAllMetaSensorItemKeyByDisplayItem(metaSensorDisplayItem)
|
||||
.pipe(
|
||||
map((result: MetaSensorItemKey[]) => {
|
||||
return new ReadAllMetaSensorItemKeyByDisplayItemSuccess(result);
|
||||
}),
|
||||
catchError(error => of(new ReadAllMetaSensorItemKeyByDisplayItemFailure(error)))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { ActionType, Actions } from './meta-sensor-display-mapping.action';
|
||||
import {
|
||||
State,
|
||||
initialState,
|
||||
metaCrawlerEntityAdapter,
|
||||
} from './meta-sensor-display-mapping.state';
|
||||
|
||||
export function reducer(state: State = initialState, action: Actions): State {
|
||||
switch (action.type) {
|
||||
|
||||
default: {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
|
||||
import { Selector, createSelector } from '@ngrx/store';
|
||||
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';
|
||||
import { MetaSensorDisplayMapping } from '@overflow/commons-typescript/model/meta';
|
||||
|
||||
export const metaCrawlerEntityAdapter = createEntityAdapter<MetaSensorDisplayMapping, RPCClientError>();
|
||||
export interface State extends EntityState<MetaSensorDisplayMapping, RPCClientError> {
|
||||
}
|
||||
export const initialState: State = metaCrawlerEntityAdapter.getInitialState({
|
||||
});
|
||||
|
||||
export function getSelectors(selector: Selector<any, State>) {
|
||||
return {
|
||||
...metaCrawlerEntityAdapter.getSelectors(selector),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user