当前位置: 首页>>代码示例>>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;未经允许,请勿转载。