当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript arkhamjs.Flux类代码示例

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


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

示例1: updateContent

 static updateContent(content: string): Promise<FluxAction> {
   return Flux.dispatch({content, type: AppConstants.UPDATE_CONTENT});
 }
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:3,代码来源:AppActions.ts

示例2: beforeAll

 beforeAll(async () => {
   await Flux.init({
     stores: [TestStore]
   });
 });
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:5,代码来源:Logger.test.ts

示例3: createStore

export const createArkhamStore = (configuration: ArkhamReduxStoreType): Store<any> => {
  const {
    arkhamMiddleware: middleware = [],
    flux,
    reducers,
    sagas,
    statePath = '',
    reduxMiddleware = [],
    devTools
  } = configuration;

  // Save initial state tree
  const {storage} = Flux.getOptions();
  let store: Store;

  if(storage) {
    const cachedState = Flux.getState(statePath);

    if(devTools) {
      store = createStore(
        devTools(reducers, cachedState),
        applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux)));
    } else {
      store = createStore(
        reducers,
        cachedState,
        applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux)));
    }

    if(cachedState === undefined) {
      const stateTree = store.getState();
      const updatedState = isPlainObject(stateTree) ? merge(stateTree, cachedState) : stateTree;
      Flux.setState(statePath, updatedState);
    }
  } else {
    store = createStore(
      reducers,
      devTools,
      applyMiddleware(...reduxMiddleware, arkhamMiddleware(statePath, flux))
    );

    Flux.setState(statePath, store.getState());
  }

  // If saga is being added, run.
  reduxMiddleware.every((item: any) => {
    if(sagas) {
      item.run(sagas);
      return false;
    }

    return true;
  });

  // Add redux middleware to Arkham to relay dispatches to Redux
  middleware.push(new ReduxMiddleware(store, statePath));

  // Initialize ArkhamJS
  Flux.addMiddleware(middleware);

  return store;
};
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:62,代码来源:createArkhamStore.ts

示例4:

 listeners.forEach(({handler, type}: FluxActionListener) => {
   Flux.off(type, handler);
 });
开发者ID:nitrogenlabs,项目名称:nl-flux,代码行数:3,代码来源:useFlux.ts


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