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

TypeScript typescript-fsa-reducers.reducerWithInitialState函数代码示例

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

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



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

示例1: reducers

export default function reducers(workerProxy: WorkerProxy): Reducer<FrameState> {
  const state = initialState(workerProxy)

  const tempReducer = reducerWithInitialState(state.temp)
    .case(actions.didReceiveMnemonic, actions.didReceiveMnemonicHandler)
    .case(actions.didStoreMnemonic, actions.didStoreMnemonicHandler)
    .case(actions.didAcknowledgeDeposit, actions.didAcknowledgeDepositHandler)
    .case(actions.setWorkerProxy, actions.setWorkerProxyHandler)

  const sharedReducer = reducerWithInitialState(state.shared)
    .case(actions.setSharedState, actions.setSharedStateHandler)
    .case(actions.setPending, actions.setPendingHandler)

  const walletReducer = reducerWithInitialState(state.wallet)
    .case(actions.updateBalance, actions.updateBalanceHandler)
    .case(actions.updateAddress, actions.updateAddressHandler)

  return redux.combineReducers({
    temp: tempReducer,
    shared: sharedReducer,
    menu: topmenu,
    wallet: walletReducer,
  });
}
开发者ID:8001800,项目名称:SpankCard,代码行数:24,代码来源:reducers.ts


示例2: fitBounds

          Math.min(...geos.map(g => g.southwest.lon)),
          Math.min(...geos.map(g => g.southwest.lat)),
        ],
      ];

      const { latitude, longitude, zoom } = fitBounds({
        bounds,
        height,
        width,
      });
      dispatch(transitionViewport({ latitude, longitude, zoom }));
    }
  },
);

export const reducer = reducerWithInitialState(SAFE_INIT)
  .case(
    addFilter,
    (original, filters) => {
      const result = { ...original };
      Object.keys(filters).forEach(filterName => {
        result[filterName] = result[filterName].add(filters[filterName]);
      });
      return result;
    },
  )
  .case(
    removeFilter,
    (original, filters) => {
      const result = { ...original };
      Object.keys(filters).forEach(filterName => {
开发者ID:cmc333333,项目名称:mapusaurus,代码行数:31,代码来源:Filters.ts


示例3: reducerWithInitialState

import { InfraNodeType } from '../../../../server/lib/adapters/nodes';
import { changeGroupBy, changeMetric, changeNodeType } from './actions';

export interface WaffleOptionsState {
  metric: InfraMetricInput;
  groupBy: InfraPathInput[];
  nodeType: InfraNodeType;
}

export const initialWaffleOptionsState: WaffleOptionsState = {
  metric: { type: InfraMetricType.cpu },
  groupBy: [],
  nodeType: InfraNodeType.host,
};

const currentMetricReducer = reducerWithInitialState(initialWaffleOptionsState.metric).case(
  changeMetric,
  (current, target) => target
);

const currentGroupByReducer = reducerWithInitialState(initialWaffleOptionsState.groupBy).case(
  changeGroupBy,
  (current, target) => target
);

const currentNodeTypeReducer = reducerWithInitialState(initialWaffleOptionsState.nodeType).case(
  changeNodeType,
  (current, target) => target
);

export const waffleOptionsReducer = combineReducers<WaffleOptionsState>({
开发者ID:salihkardan,项目名称:kibana,代码行数:31,代码来源:reducer.ts


示例4: reducerWithInitialState

      },
      users: {
        limit: DEFAULT_TABLE_LIMIT,
        usersSortField: {
          field: UsersFields.name,
          direction: Direction.asc,
        },
      },
    },
    filterQuery: null,
    filterQueryDraft: null,
    flowTarget: FlowTarget.source,
  },
};

export const networkReducer = reducerWithInitialState(initialNetworkState)
  .case(updateDnsLimit, (state, { limit, networkType }) => ({
    ...state,
    [networkType]: {
      ...state[networkType],
      queries: {
        ...state[networkType].queries,
        dns: {
          ...state[NetworkType.page].queries.dns,
          limit,
        },
      },
    },
  }))
  .case(updateDnsSort, (state, { dnsSortField, networkType }) => ({
    ...state,
开发者ID:,项目名称:,代码行数:31,代码来源:


示例5: reducerWithInitialState

import { State } from './index';

export const defaultState: State = {
  token: null,
  scopes: null,
  expiration: null,
  loggedInAsCustomer: false
};

const {
  token: tokenInLocalStorage,
  scopes: scopesInLocalStorage,
  expire: expiryInLocalStorage
} = authentication;

const reducer = reducerWithInitialState(defaultState)
  .case(handleStartSession, (state, payload) => {
    const { scopes, token, expires } = payload;

    /** set local storage */
    scopesInLocalStorage.set(scopes || '');
    tokenInLocalStorage.set(token || '');
    expiryInLocalStorage.set(expires || '');

    /** set redux state */
    return {
      ...state,
      token: token || null,
      scopes: scopes || null,
      expiration: expires || null
    };
开发者ID:linode,项目名称:manager,代码行数:31,代码来源:authentication.reducer.ts


示例6: characterReducer

const summonMinionHandler = (state: EntityContainer, payload: Minion): EntityContainer =>
  R.assoc(payload.id, payload, state);

const processDeathsHandler = R.reject(
  R.whereEq({ destroyed: true, type: CardType.Minion })
);

// TODO: refactor
const characterHandler = (
  state: EntityContainer,
  action: Action<EntityPayload<Object>>
): EntityContainer =>
  R.evolve(
    {
      [action.payload.id]: (character: Character) =>
        characterReducer(character, action),
    },
    state
  );

export default reducerWithInitialState<EntityContainer>(board)
  .case(nextTurn, nextTurnHandler)
  .case(summonMinion, summonMinionHandler)
  .case(processDeaths, processDeathsHandler)
  // TODO: we can give 4 elements maximum to casesWithAction method in order to make inference possible
  .casesWithAction([attackCharacter, dealDamage, exhaust, destroyWeapon], characterHandler)
  .casesWithAction(
    [equipWeapon, gainMana, restoreMana, spendMana],
    characterHandler
  );
开发者ID:zernie,项目名称:typescript-redux-card-game,代码行数:30,代码来源:boardReducer.ts


示例7: dispatch

  if (
    player.playState === PlayState.Lost ||
    opponent.playState === PlayState.Lost
  ) {
    dispatch(finishGame());
  }
};

export const endTurn = (): ThunkAction<void, Game, {}> => (
  dispatch,
  getState
) => {
  dispatch(nextTurn());
  const state = getState();

  const player = activeHero(state);

  dispatch(gainMana({ id: player.id }));
  dispatch(restoreMana({ id: player.id }));

  const cards = R.values(selectCards(player.owner, getDeck(state)));

  if (cards.length > 0) {
    dispatch(drawCard(cards[0].id));
  }
};

export default reducerWithInitialState<State>(initialState.state)
  .case(nextTurn, nextTurnHandler)
  .case(finishGame, finishGameHandler);
开发者ID:zernie,项目名称:typescript-redux-card-game,代码行数:30,代码来源:gameStateReducer.ts


示例8: reducerWithInitialState

  customOptions: InfraGroupByOptions[];
  boundsOverride: InfraWaffleMapBounds;
  autoBounds: boolean;
}

export const initialWaffleOptionsState: WaffleOptionsState = {
  metric: { type: InfraSnapshotMetricType.cpu },
  groupBy: [],
  nodeType: InfraNodeType.host,
  view: 'map',
  customOptions: [],
  boundsOverride: { max: 1, min: 0 },
  autoBounds: true,
};

const currentMetricReducer = reducerWithInitialState(initialWaffleOptionsState.metric).case(
  changeMetric,
  (current, target) => target
);

const currentCustomOptionsReducer = reducerWithInitialState(
  initialWaffleOptionsState.customOptions
).case(changeCustomOptions, (current, target) => target);

const currentGroupByReducer = reducerWithInitialState(initialWaffleOptionsState.groupBy).case(
  changeGroupBy,
  (current, target) => target
);

const currentNodeTypeReducer = reducerWithInitialState(initialWaffleOptionsState.nodeType).case(
  changeNodeType,
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:reducer.ts


示例9: if

      if (queryParams.type.includes('one-click')) {
        return 'fromApp';
      } else if (queryParams.type.includes('images')) {
        return 'fromImage';
      } else {
        return 'fromImage';
      }
    }
  }

  /** always backup to 'fromImage' */
  return 'fromImage';
};

export const defaultState: State = {
  type: getInitialType()
};

const reducer: Reducer<State> = reducerWithInitialState(
  defaultState
).caseWithAction(handleChangeCreateType, (state, action) => {
  const { payload } = action;

  return {
    ...state,
    type: payload
  };
});

export default reducer;
开发者ID:linode,项目名称:manager,代码行数:30,代码来源:linodeCreate.reducer.ts


示例10: reducerWithInitialState

import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { increment, decrement } from './actions';

export type State = { count: number };

const initialState: State = {
  count: 0
};

export const reducer = reducerWithInitialState(initialState)
    .case(increment, (state, payload) => {
      return {
        ...state,
        count: state.count + payload.incrementBy
      };
    })
    .case(decrement, (state, payload) => {
      return {
        ...state,
        count: state.count - payload.incrementBy
      };
    });
开发者ID:stevejhiggs,项目名称:macgyver,代码行数:22,代码来源:reducer.ts


示例11: reducerWithInitialState

import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { loadAnimals } from './actions';

export interface Animal {
  id: number;
  name: string;
}

export type State = Animal[];

export const reducer = reducerWithInitialState([] as Animal[])
  .case(loadAnimals.async.done, (state, payload) => {
    return payload.result;
  });
开发者ID:stevejhiggs,项目名称:macgyver,代码行数:14,代码来源:reducer.ts


示例12: omit

}

export const registerProviderHandler = ({
  provider,
  dataProviders,
}: RegisterProviderHandlerParams): IdToDataProvider => ({
  ...dataProviders,
  [provider.id]: provider,
});

interface UnRegisterProviderHandlerParams {
  id: string;
  dataProviders: IdToDataProvider;
}

export const unRegisterProviderHandler = ({
  id,
  dataProviders,
}: UnRegisterProviderHandlerParams): IdToDataProvider => omit(id, dataProviders);

export const dragAndDropReducer = reducerWithInitialState(initialDragAndDropState)
  .case(registerProvider, (state, { provider }) => ({
    ...state,
    dataProviders: registerProviderHandler({ provider, dataProviders: state.dataProviders }),
  }))
  .case(unRegisterProvider, (state, { id }) => ({
    ...state,
    dataProviders: unRegisterProviderHandler({ id, dataProviders: state.dataProviders }),
  }))
  .build();
开发者ID:,项目名称:,代码行数:30,代码来源:


示例13: reducerWithInitialState

import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { setVisibilityFilter } from '../actions';
import { Filter } from '../types';

const reducer = reducerWithInitialState(Filter.SHOW_ALL)
	.case(setVisibilityFilter, setVisibilityFilterHandler);
	
function setVisibilityFilterHandler(state: string, filter: Filter) {
	return filter;
}

export default reducer;
开发者ID:pslotinsky,项目名称:todos,代码行数:12,代码来源:visibilityFilter.ts


示例14: reducerWithInitialState

import { hideFlyout, setFlyoutItem, showFlyout } from './actions';

export enum FlyoutVisibility {
  hidden = 'hidden',
  visible = 'visible',
}

export interface FlyoutOptionsState {
  visibility: FlyoutVisibility;
  itemId: string;
}

export const initialFlyoutOptionsState: FlyoutOptionsState = {
  visibility: FlyoutVisibility.hidden,
  itemId: '',
};

const currentFlyoutReducer = reducerWithInitialState(initialFlyoutOptionsState.itemId).case(
  setFlyoutItem,
  (current, target) => target
);

const currentFlyoutVisibilityReducer = reducerWithInitialState(initialFlyoutOptionsState.visibility)
  .case(hideFlyout, () => FlyoutVisibility.hidden)
  .case(showFlyout, () => FlyoutVisibility.visible);

export const flyoutOptionsReducer = combineReducers<FlyoutOptionsState>({
  itemId: currentFlyoutReducer,
  visibility: currentFlyoutVisibilityReducer,
});
开发者ID:lucabelluccini,项目名称:kibana,代码行数:30,代码来源:reducer.ts


示例15: suggestionReducer

    suggestions: suggestionReducer(undefined, "" as any),
};

export const GUEST_USER_ID = 0;

/**
 * Determine if a user fragment is a guest.
 */
export function isUserGuest(user: IUserFragment | null | undefined) {
    return user && user.userID === GUEST_USER_ID;
}
/**
 * Reducer for user related data.
 */
export const usersReducer = produce(
    reducerWithInitialState(INITIAL_STATE)
        .case(UserActions.getMeACs.started, state => {
            state.current.status = LoadStatus.LOADING;
            return state;
        })
        .case(UserActions.getMeACs.done, (state, payload) => {
            state.current.data = payload.result;
            state.current.status = LoadStatus.SUCCESS;
            return state;
        })
        .case(UserActions.getMeACs.failed, (state, payload) => {
            state.current.status = LoadStatus.ERROR;
            state.current.error = payload.error;
            return state;
        })
        .case(UserActions.getCountsACs.started, state => {
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:userModel.ts


示例16: reducerWithInitialState

import {INITIAL_STATE, WorkerState} from './WorkerState'
import {reducerWithInitialState, ReducerBuilder} from 'typescript-fsa-reducers'
import * as actions from './actions'

const reducers: ReducerBuilder<WorkerState, WorkerState> = reducerWithInitialState(INITIAL_STATE)
  .case(actions.setWallet, actions.setWalletHandler)
  .case(actions.setKeyring, actions.setKeyringHandler)
  .case(actions.setDidStoreMnemonic, actions.setDidStoreMnemonicHandler)
  .case(actions.restoreWallet, actions.restoreWalletHandler)
  .case(actions.setTransactionPending, actions.setTransactionPendingHandler)
  .case(actions.openChannel, actions.openChannelHandler)
  .case(actions.removePendingChannel, actions.removePendingChannelHandler)
  .case(actions.rememberPage, actions.rememberPageHandler)
  .case(actions.setLastUpdateDb, actions.setLastUpdateDbHandler)
  .case(actions.setHubBranding, actions.setHubBrandingHandler)
  .case(actions.setCurrentHubUrl, actions.setCurrentHubUrlHandler)
  .case(actions.setCurrentAuthRealm, actions.setCurrentAuthRealmHandler)
  .case(actions.toggleFrame, actions.toggleFrameHandler)
  .case(actions.setChannels, actions.setChannelsHandler)
  .case(actions.setChannel, actions.setChannelHandler)
  .case(actions.setCurrentAuthToken, actions.setCurrentAuthTokenHandler)
  .case(actions.setHistory, actions.setHistoryHandler)
  .case(actions.setBalance, actions.setBalanceHandler)
  .case(actions.setPendingTransaction, actions.setPendingTransactionHandler)
  .case(actions.reset, actions.resetHandler)
  .case(actions.setHasActiveWithdrawal, actions.setHasActiveWithdrawalHandler)

export default reducers
开发者ID:8001800,项目名称:SpankCard,代码行数:28,代码来源:reducers.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript dist.reducerWithInitialState函数代码示例发布时间:2022-05-25
下一篇:
TypeScript typescript-fsa.isType函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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