當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript store.createFeatureSelector函數代碼示例

本文整理匯總了TypeScript中@ngrx/store.createFeatureSelector函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createFeatureSelector函數的具體用法?TypeScript createFeatureSelector怎麽用?TypeScript createFeatureSelector使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createFeatureSelector函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

import { RouterStateUrl } from './router/router.state';

export const reducers: ActionReducerMap<AppState> = {
  auth: authReducer,
  router: routerReducer
};

export const metaReducers: MetaReducer<AppState>[] = [
  initStateFromLocalStorage
];
if (!environment.production) {
  metaReducers.unshift(storeFreeze);
  if (!environment.test) {
    metaReducers.unshift(debug);
  }
}

export const selectAuthState = createFeatureSelector<AppState, AuthState>(
  'auth'
);

export const selectRouterState = createFeatureSelector<
  AppState,
  RouterReducerState<RouterStateUrl>
>('router');

export interface AppState {
  auth: AuthState;
  router: RouterReducerState<RouterStateUrl>;
}
開發者ID:tormentedhollow,項目名稱:angular-ngrx-material-starter,代碼行數:30,代碼來源:core.state.ts

示例2: createSelector

/**
 * Our state is composed of a map of action reducer functions.
 * These reducer functions are called with each dispatched action
 * and the current or initial state and return a new immutable state.
 */
export const reducers: ActionReducerMap<State> = {
  filters: fromFilters.reducer,
  quarters: fromQuarter.reducer,
  pai: fromPai.reducer,
  search: fromSearch.reducer,
};

/**
 * Layout Reducers
 */
export const getPaiState = createFeatureSelector<fromPai.State>('pai');
export const getFiltersState = createFeatureSelector<fromFilters.State>('filters');
export const getQuartersState = createFeatureSelector<fromQuarter.State>('quarters');
export const getSearchState = createFeatureSelector<fromSearch.State>('search');

export const getFiltersEntities = createSelector(
  getFiltersState,
  fromFilters.getEntities
);

export const getSelectedFilters = createSelector(
  getFiltersState,
  fromFilters.getSelectedFilters
);

export const getQuartersEntities = createSelector(
開發者ID:hasadna,項目名稱:open_pension,代碼行數:31,代碼來源:index.ts

示例3: reducer

export interface PodcastState {
	podcast: Podcast;
	items: Page<Item>;
}

const initialState: PodcastState = {
	podcast: null,
	items: null
};

export function reducer(state = initialState, action: PodcastActions): PodcastState {
	switch (action.type) {
		case PodcastAction.FIND_ONE_SUCCESS: {
			return { ...state, podcast: action.podcast };
		}

		case PodcastAction.FIND_ITEMS_SUCCESS: {
			return { ...state, items: action.items };
		}

		default: {
			return state;
		}
	}
}

const moduleSelector = createFeatureSelector<PodcastState>('podcast');
export const selectPodcast = createSelector(moduleSelector, (s: PodcastState) => s.podcast);
export const selectPodcastItems = createSelector(moduleSelector, (s: PodcastState) => s.items);
開發者ID:davinkevin,項目名稱:Podcast-Server,代碼行數:29,代碼來源:podcast.reducer.ts

示例4: createSelector

// Ngrx
import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/store';

// Models
import { IProductModuleState } from '../../models';

// Reducers
import { ProductReducer } from './product.reducer';

export const reducers: ActionReducerMap<IProductModuleState> = {
    products: ProductReducer
};

/* =============================== Feature Selector =========================== */
export const productModuleStateSelector = createFeatureSelector<IProductModuleState>('products');

/* =============================== Product Selectors =========================== */

export const productStateSelector = createSelector(
    productModuleStateSelector,
    state => state.products
);

export const productPageRequestSelector = createSelector(
    productStateSelector,
    state => state.pageRequest
);

export const productPageSelector = createSelector(
    productStateSelector,
    state => state.data
開發者ID:MMICHIELI,項目名稱:angular7Crud,代碼行數:31,代碼來源:index.ts

示例5: createSelector

import { createFeatureSelector, createSelector } from '@ngrx/store';

export interface CoreState {
    language: string
}

export const initialState: CoreState = {
    language: null
};

export const getCoreState = createFeatureSelector<CoreState>('coreReducer');
export const getLanguage = createSelector(getCoreState, (state: CoreState) => state.language);
開發者ID:alv-ch,項目名稱:job-room,代碼行數:12,代碼來源:core.state.ts

示例6: floatingPlayer

export interface FloatingPlayerState {
	item: Item;
	display: DisplayState;
}

const initialState: FloatingPlayerState = {
	item: null,
	display: 'CLOSED'
};

export function floatingPlayer(state = initialState, action: FloatingPlayerActions): FloatingPlayerState {
	switch (action.type) {
		case FloatingPlayerAction.PLAY: {
			return { ...state, item: action.item, display: 'OPENED' };
		}

		case FloatingPlayerAction.CLOSE: {
			return { ...state, item: null, display: 'CLOSED' };
		}

		default: {
			return state;
		}
	}
}

const moduleSelector = createFeatureSelector<FloatingPlayerState>('floatingPlayer');
export const item = createSelector(moduleSelector, (s: FloatingPlayerState) => s.item);
export const display = createSelector(moduleSelector, (s: FloatingPlayerState) => s.display);
開發者ID:davinkevin,項目名稱:Podcast-Server,代碼行數:29,代碼來源:floating-player.reducer.ts

示例7: fetchSelectedFilters

import { HomeState } from './index';
import { SearchState } from './search.state';
import { createSelector, createFeatureSelector } from '@ngrx/store';

/******************* Base Search State ******************/
export const getHomeState = createFeatureSelector<HomeState>('home');

export const getSearchState = createSelector(
  getHomeState,
  (state: HomeState) => state.search
);

/******************* Individual selectors ******************/
function fetchSelectedFilters(state: SearchState) {
  return state.selectedFilters.toJS();
};

function fetchSelectedTaxonIds(state: SearchState) {
  return state.selectedTaxonIds.toJS();
}

function fetchProductsByKeyword(state: SearchState) {
  return state.productsByKeyword.toJS();
}

function fetchChildTaxons(state: SearchState) {
  return state.getChildTaxons.toJS();
}

function fetchCategeoryLevel(state: SearchState) {
  return state.categeoryLevel.toJS();
開發者ID:TrietPham96,項目名稱:angularspree,代碼行數:31,代碼來源:selectors.ts

示例8: createFeatureSelector

    'AddScatterChartData': scatterChart.AddScatterChartData,
    'UpdateRealTimeScatterChartXRange': scatterChartRealTime.UpdateRealTimeScatterChartXRange,
    'UpdateServerMapData': serverMap.UpdateServerMapData,
    'UpdateServerMapLoadingState': serverMapLoadingState.UpdateServerMapLoadingState,
    'UpdateServerMapTargetSelected': serverMapSelectedTarget.UpdateServerMapTargetSelected,
    'UpdateServerMapSelectedTargetByList': targetList.UpdateServerMapSelectedTargetByList,
    'UpdateFilterOfServerAndAgentList': serverAndAgent.UpdateFilterOfServerAndAgentList,
    'UpdateAgentInfo': agentInfo.UpdateAgentInfo,
    'UpdateAdminAgentList': admin.UpdateAdminAgentList,
    'ChangeServerMapDisableState': uiState.ChangeServerMapDisableState,
    'ChangeInfoPerServerVisibleState': uiState.ChangeInfoPerServerVisibleState,
    'UpdateTimelineData': timeline.UpdateTimelineData,
    'UpdateURLPath': urlPath.UpdateURLPath
};

const getUI = createFeatureSelector('uiState');
export const selectServerMapDisableState = createSelector(
    getUI,
    (state: IUIState) => state['serverMap']
);
export const selectInfoPerServerVisibleState = createSelector(
    getUI,
    (state: IUIState) => state['infoPerServer']
);

const getTimeline = createFeatureSelector('timeline');
export const selectTimelineRange = createSelector(
    getTimeline,
    (state: ITimelineInfo) => state['range']
);
export const selectTimelineSelectionRange = createSelector(
開發者ID:young891221,項目名稱:pinpoint,代碼行數:31,代碼來源:index.ts

示例9: createSelector

import { createFeatureSelector, createSelector } from '@ngrx/store';
import { IIdentityState } from './states/index';

export const selectIdentityState = createFeatureSelector<IIdentityState>('identity');
export const getIdentity = createSelector(selectIdentityState, state => state.identity);
開發者ID:our-city-app,項目名稱:gae-plugin-framework,代碼行數:5,代碼來源:identity.state.ts

示例10:

import { ActionReducerMap, createFeatureSelector } from '@ngrx/store';

import * as fromRoot from '../../store';
import * as fromCandidate from './candidate.reducer';

export interface CandidateState {
  candidate: fromCandidate.State;
}

export interface State extends fromRoot.State {
  candidate: CandidateState;
}

export const reducers: ActionReducerMap<CandidateState> = {
  candidate: fromCandidate.reducer
};

export const selectCandidateState = createFeatureSelector<CandidateState>(
  'candidate'
);
開發者ID:ArmyMusicOnline,項目名稱:ami,代碼行數:20,代碼來源:index.ts

示例11: sidenav

  podcast: PodcastState;
  item: ItemState;
}

export interface State {
  open: boolean;
}

const initialState: State = {
  open: false
};

export function sidenav(state = initialState, action: AppActions): State {
  switch (action.type) {

    case AppAction.OPEN_SIDE_NAV: {
      return {...state, open: true };
    }

    case AppAction.CLOSE_SIDE_NAV: {
      return {...state, open: false };
    }

    default: {return state; }

  }
}

const sideNavFeature = createFeatureSelector('sidenav');
export const selectSideNavOpen = createSelector(sideNavFeature, (s: State) => s.open);
開發者ID:davinkevin,項目名稱:Podcast-Server,代碼行數:30,代碼來源:app.reducer.ts

示例12: reducer

import { createFeatureSelector, createSelector } from '@ngrx/store';
import { UserActions, UserActionTypes } from './user.actions';

// State for this feature (User)
export interface UserState {
  maskUserName: boolean;
  currentUser: User;
}

const initialState: UserState = {
  maskUserName: true,
  currentUser: null
};

// Selector functions
const getProductFeatureState = createFeatureSelector<UserState>('users');

export const getMaskUserName = createSelector(
  getProductFeatureState,
  state => state.maskUserName
);

export const getCurrentUser = createSelector(
  getProductFeatureState,
  state => state.currentUser
);

export function reducer(state = initialState, action: UserActions): UserState {
  switch (action.type) {
    case UserActionTypes.MaskUserName:
      return {
開發者ID:huytq1,項目名稱:Angular-NgRx-GettingStarted,代碼行數:31,代碼來源:user.reducer.ts

示例13: deleteBin

  return Object.assign({}, state, {
    selectedBinID: action.payload
  });
}

function deleteBin(state: State, action: BinEstimatorActions.DeleteBinAction) {
  if (action.payload === state.selectedBinID) {
    return Object.assign({}, state, {
      selectedBinID: null
    })
  } else {
    return state;
  }
}

export const selectBinEstimatorState = createFeatureSelector<State>('binEstimators');
export const selectAppState = createSelector(selectBinEstimatorState, (state: State) => state.appState);
export const selectLoadingBinEstimators = createSelector(selectBinEstimatorState, (state: State) => state.loadingBinEstimators);
export const selectBinEstimatorsLoaded = createSelector(selectBinEstimatorState, (state: State) => state.binEstimatorsLoaded);
export const selectActiveBinEstimatorID = createSelector(selectBinEstimatorState, (state: State) => state.activeBinEstimatorID);
export const selectActiveLocusBinSetID = createSelector(selectBinEstimatorState, (state: State) => state.activeLocusBinSetID);
export const selectSelectedBinID = createSelector(selectBinEstimatorState, (state: State) => state.selectedBinID);

export const selectActiveBinEstimator = createSelector(fromDB.selectBinEstimatorProjectEntities, selectActiveBinEstimatorID, (entities, id): BinEstimatorProject => entities[id]);
export const selectActiveLocusSet = createSelector(fromDB.selectLocusSetEntities, selectActiveBinEstimator, (locusSets, binEstimator): LocusSet => {
  if (locusSets && binEstimator) {
    return locusSets[binEstimator.locus_set];
  } else {
    return null;
  }
});
開發者ID:Greenhouse-Lab,項目名稱:MicroSPAT,代碼行數:31,代碼來源:bin-estimators.ts

示例14: setTask

  return setTask(state, action);
}

function taskCompleted(state: State, action: TaskActions.TaskSuccessAction) {
  return setTask(state, action);
}

function clearTask(state: State, action: TaskActions.ClearTaskAction) {
  const taskId = action.payload;
  const {[taskId]: taskToRemove, ...remainingTasks} = state.tasks;
  return Object.assign({}, state, {
    tasks: remainingTasks,
  });
}

export const selectTasksState = createFeatureSelector<State>('tasks');

export function selectTask(id: string) {
  return createSelector(selectTasksState, (state) => state.tasks[id])
}


export function selectActiveTasks(namespace: string = null, taskType: string = null) {
  return createSelector(selectTasksState, fromDB.selectAnyGetsInFlight, (state: State, getsInFlight: boolean): Task[] => {
    const activeTasks = Object.keys(state.tasks)
      .filter(id => {
        const e = state.tasks[id];
        if (namespace && e.namespace !== namespace) {
          return false;
        }
        if (taskType && e.task !== taskType) {
開發者ID:Greenhouse-Lab,項目名稱:MicroSPAT,代碼行數:31,代碼來源:tasks.ts

示例15: createSelector

import {createFeatureSelector, createSelector} from '@ngrx/store';
import {State} from './reducer';

export const getState = createFeatureSelector<State>('productState');
export const getQuantity = createSelector(getState, state => state.productQuantity);
export const getErrorMessage = createSelector(getState, state => state.error);
開發者ID:yfain,項目名稱:observables,代碼行數:6,代碼來源:selectors.ts


注:本文中的@ngrx/store.createFeatureSelector函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。