reducer is added
This commit is contained in:
parent
07528f5629
commit
b934474aa3
|
@ -11,7 +11,7 @@ export const effects: Type<any>[] = [VersionInfoStore.Effects];
|
||||||
|
|
||||||
export function reducers(state: State | undefined, action: Action) {
|
export function reducers(state: State | undefined, action: Action) {
|
||||||
return combineReducers({
|
return combineReducers({
|
||||||
versionInfo: VersionInfoStore.reducers
|
versionInfo: VersionInfoStore.reducer
|
||||||
})(state, action);
|
})(state, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
import { Action, combineReducers } from '@ngrx/store';
|
import { createReducer, on } from '@ngrx/store';
|
||||||
import { State } from './state';
|
import { initialState } from './state';
|
||||||
|
import { fetchSuccess } from './actions';
|
||||||
|
|
||||||
export function reducers(state: State | undefined, action: Action) {
|
export const reducer = createReducer(
|
||||||
return combineReducers({})(state, action);
|
initialState,
|
||||||
}
|
on(fetchSuccess, (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
profileImageRoot: action.profileRoot,
|
||||||
|
profileImageUploadUrl: action.profileUploadUrl,
|
||||||
|
fileUploadMaxSize:
|
||||||
|
!!action.fileAllowSize &&
|
||||||
|
!isNaN(action.fileAllowSize) &&
|
||||||
|
0 < action.fileAllowSize
|
||||||
|
? action.fileAllowSize
|
||||||
|
: 0,
|
||||||
|
fileUploadUrl: action.uploadUrl,
|
||||||
|
fileDownloadUrl: action.downloadUrl,
|
||||||
|
serverIp: action.serverIp
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
|
@ -1,10 +1,49 @@
|
||||||
import { Selector } from '@ngrx/store';
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
// tslint:disable-next-line: no-empty-interface
|
// tslint:disable-next-line: no-empty-interface
|
||||||
export interface State {}
|
export interface State {
|
||||||
|
profileImageRoot: string | null;
|
||||||
|
profileImageUploadUrl: string | null;
|
||||||
|
fileUploadMaxSize: number | null;
|
||||||
|
fileUploadUrl: string | null;
|
||||||
|
fileDownloadUrl: string | null;
|
||||||
|
serverIp: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export const initialState: State = {};
|
export const initialState: State = {
|
||||||
|
profileImageRoot: null,
|
||||||
|
profileImageUploadUrl: null,
|
||||||
|
fileUploadMaxSize: null,
|
||||||
|
fileUploadUrl: null,
|
||||||
|
fileDownloadUrl: null,
|
||||||
|
serverIp: null
|
||||||
|
};
|
||||||
|
|
||||||
export function selectors<S>(selector: Selector<any, State>) {
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
return {};
|
return {
|
||||||
|
profileImageRoot: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.profileImageRoot
|
||||||
|
),
|
||||||
|
profileImageUploadUrl: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.profileImageUploadUrl
|
||||||
|
),
|
||||||
|
fileUploadMaxSize: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.fileUploadMaxSize
|
||||||
|
),
|
||||||
|
fileUploadUrl: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.fileUploadUrl
|
||||||
|
),
|
||||||
|
fileDownloadUrl: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.fileDownloadUrl
|
||||||
|
),
|
||||||
|
serverIp: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.serverIp
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user