• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript store.createFeatureSelector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ngrx/store.createFeatureSelector函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createFeatureSelector函数的具体用法?TypeScript createFeatureSelector怎么用?TypeScript createFeatureSelector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createFeatureSelector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: getCurrentSpace

import { Injectable } from '@angular/core';

// MemoizedSelector is needed even if it's not being used in this file
// Else you get this error
// Exported variable 'plannerSelector' has or is using name 'MemoizedSelector'
// from external module "@ngrx/store/src/selector" but cannot be named.
import { createFeatureSelector, createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
import { Space } from 'ngx-fabric8-wit';
import { Observable } from 'rxjs';
import { filter, tap } from 'rxjs/operators';
import * as SpaceActions from './../actions/space.actions';
import { AppState, PlannerState } from './../states/app.state';

export const plannerSelector = createFeatureSelector<PlannerState>('planner');
export const spaceSelector = createSelector(
    plannerSelector,
    // TODO
    // This is a HACK till fabric8-ui removes the unnecessary planner imports
    // it should just be
    // state => state.space
    state => state ? state.space : {} as Space
);
@Injectable()
export class SpaceQuery {
    constructor(private store: Store<AppState>) {}

    get getCurrentSpace(): Observable<Space> {
        return this.store.pipe(
            select(spaceSelector),
            tap(s => {if (!s) { this.store.dispatch(new SpaceActions.Get()); }}),
            filter(s => !!s)
开发者ID:joshuawilson,项目名称:almighty-ui,代码行数:31,代码来源:space.ts


示例17: createSelector

import * as fromArticles from './articles';
import { ActionReducerMap, createFeatureSelector, createSelector } from '@ngrx/store';

export interface ArticlesState {
    articles: fromArticles.State;
}

export interface State extends fromRoot.State {
    articles: ArticlesState;
}

export const reducers: ActionReducerMap<ArticlesState> = {
    articles: fromArticles.reducer,
};

export const getArticlesState = createFeatureSelector<ArticlesState>('articles');

export const getArticlesEntities = createSelector(
    getArticlesState,
    state => state.articles
);



export const getSelectedArticleId = createSelector(
    getArticlesEntities,
    fromArticles.getSelectedId
);

export const getArticles = createSelector(
    getArticlesEntities,
开发者ID:evcraddock,项目名称:erikvancraddock.com,代码行数:31,代码来源:index.ts


示例18:

    case I18NActions.FETCH_FAIL: {
      return {
        ...state,
        onSync: false,
        onError: true
      };
    }

    case I18NActions.APPEND_APP_DETAILS: {
      const dictionary = {
        ...state.dictionary,
        ...(action as I18NActions.I18NAppendAppDetails).payload
      };

      return {
        ...state,
        dictionary,
        onSync: false,
        onError: false
      };
    }

    default: {
      return state;
    }
  }
}

export const selectI18NState = createFeatureSelector<I18NState>('i18nState');
开发者ID:gnodet,项目名称:syndesis,代码行数:29,代码来源:i18n.reducer.ts


示例19: loadingLadders

      laddersLoaded: true
    });
  }
  return state;
}

function loadingLadders(state, action) {
  return Object.assign({}, state, {
    loadingLadders: true
  });
}

function selectLadder(state, action) {
  return Object.assign({}, state, {
    activeLadderID: action.payload
  });
}

function unselectLadder(state, action) {
  return Object.assign({}, state, {
    activeLadderID: null
  })
}

export const selectLadderState = createFeatureSelector<State>('ladders');
export const selectLoadingLadders = createSelector(selectLadderState, (state: State) => state.loadingLadders);
export const selectLaddersLoaded = createSelector(selectLadderState, (state: State) => state.laddersLoaded);
export const selectActiveLadderID = createSelector(selectLadderState, (state: State) => state.activeLadderID);

export const selectActiveLadder = createSelector(fromDB.selectLadderEntities, selectActiveLadderID, (entities, id): Ladder => entities[id]);
开发者ID:Greenhouse-Lab,项目名称:MicroSPAT,代码行数:30,代码来源:ladders.ts


示例20: logger

} from '@ngrx/store';
import { environment } from '../../environments/environment';
import * as fromRouter from '@ngrx/router-store';
// import { storeFreeze } from 'ngrx-store-freeze';

export interface State {
  router: fromRouter.RouterReducerState;
}


export const reducers: ActionReducerMap<State> = {
  router: fromRouter.routerReducer,
};

// console.log all actions. Can be useful if DevTools not installed
export function logger(reducer: ActionReducer<State>): ActionReducer<State> {
  return function(state: State, action: any): State {
    console.log('state', state);
    console.log('action', action);

    return reducer(state, action);
  };
}

export const metaReducers: MetaReducer<State>[] = !environment.production
  ? [/* logger, */ /* storeFreeze */]
  : [];


export const selectRouterState = createFeatureSelector<fromRouter.RouterReducerState>('router');
开发者ID:ArmyMusicOnline,项目名称:ami,代码行数:30,代码来源:index.ts



注:本文中的@ngrx/store.createFeatureSelector函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript store.createMiddleware函数代码示例发布时间:2022-05-28
下一篇:
TypeScript store.compose函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap