我正在通过这封信做所有事情,但是redux-devtools并没有在我的状态中显示任何差异。我的代码
import { storeFreeze } from 'ngrx-store-freeze';
import { storeLogger } from 'ngrx-store-logger';
import {
ActionReducerMap,
createSelector,
createFeatureSelector,
ActionReducer,
MetaReducer,
} from '@ngrx/store';
import { ResultInteface } from '../models/results';
import * as search from '../actions/search';
import { environment } from '../../environments/environment';
export interface SearchState {
queryString: string;
messages: string[];
results: ResultInteface[];
loading: boolean;
}
export interface State {
search: SearchState;
}
export const intialState: SearchState = {
queryString: '',
messages: [],
results: [],
loading: false
};
export function searchReducers(state = intialState, action: search.Actions): SearchState {
switch (action.type) {
case search.SEARCH_COUNTRY:
state.queryString = action.payload;
return state;
case search.SEARCH_COUNTRY_ISO2:
return state;
case search.SEARCH_COUNTRY_ISO3:
return state;
case search.SEARCH_COUNTRY_COMPLETE:
state.messages = action.payload.RestResponse.messages;
state.results = action.payload.RestResponse.result;
return state;
default:
return state;
}
}
export const reducers: ActionReducerMap<State> = {
search: searchReducers
};
export function logger(reducer: ActionReducer<State>): any {
return storeLogger()(reducer);
}
export const getResults = (state: SearchState) => state.results;
export const getSearchState = createFeatureSelector<SearchState>('search');
export const getSearchResults = createSelector(
getSearchState,
getResults
);