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

TypeScript redux-saga.default函数代码示例

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

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



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

示例1: default

export default (history: History, dsn: string) => {
  const sagaMiddleware: SagaMiddleware<{}> = createSagaMiddleware();
  let middlewares: Middleware[] = [];
  if (process.env.NODE_ENV !== 'production') {
    middlewares = [
      createLogger(),
    ];
  }
  Raven.config(dsn).install();
  const devtools: any = process.env.NODE_ENV !== 'production' && (window as any)._REDUX_DEVTOOLS_EXTENSION__ ?
    (window as any)._REDUX_DEVTOOLS_EXTENSION__() : (f: any) => f;
  const store = createStore(
    createRootReducer(history),
    compose(
      applyMiddleware(
        routerMiddleware(history),
        googleAnalytics,
        sagaMiddleware,
        createRavenMiddleware(Raven, {}),
        ...middlewares,
      ),
      devtools,
    ),
  );
  sagaMiddleware.run(rootSaga);
  return store;
};
开发者ID:8398a7,项目名称:8398a7.github.io,代码行数:27,代码来源:store.ts


示例2: createSagaMiddleware

export const configureStore = () => {
  const sagaMiddleware = createSagaMiddleware()
  const logger = createLogger()
  const store = createStore(
    persistReducer({ key: 'reversi', storage, whitelist: ['history'] }, reducer),
    compose(
      applyMiddleware(sagaMiddleware, logger),
      getDevtools()
    )
  )
  const persistor = persistStore(store)

  if (module.hot) {
    module.hot.accept('./reducer', () => {
      store.replaceReducer(require('./reducer').default)
    })
  }

  return {
    store,
    persistor,
    runSaga: sagaMiddleware.run,
    close () {
      store.dispatch(END as any)
    }
  }
}
开发者ID:DanSnow,项目名称:react-reversi,代码行数:27,代码来源:store.ts


示例3: configureStore

export function configureStore(preloadedState?: IApplicationState): SagaEnhancedStore<IApplicationState> {
  const sagaMiddleware = createSagaMiddleware()

  const middlewares = [
    routerMiddleware(browserHistory),
    sagaMiddleware,
  ]

  const store = createStore<IApplicationState | undefined>(
    rootReducer,
    preloadedState,
    compose<any, any>(
      applyMiddleware(...middlewares),
      devTools(),
    ),
  ) as SagaEnhancedStore<IApplicationState>

  sagaMiddleware.run(rootSaga)

  store.runSaga = sagaMiddleware.run
  store.close = () => store.dispatch(END)

  // Hot reload reducers:
  // https://github.com/reactjs/react-redux/releases/tag/v2.0.0
  /* tslint:disable:no-string-literal */
  if (process.env.NODE_ENV === "development" && module["hot"]) {
    module["hot"].accept("./reducers", () => {
      const nextRootReducer = require("./reducers").default
      store.replaceReducer(nextRootReducer)
    })
  }
  /* tslint:enable:no-string-literal */

  return store
}
开发者ID:goblindegook,项目名称:dictionary-react-redux-typescript,代码行数:35,代码来源:store.ts


示例4: configureStore

export default function configureStore(initialState: DeepPartial<RootState>) {
  const sagaMiddleware = createSagaMiddleware();
  
  const middleware = [
    sagaMiddleware
  ];

  const composeEnhancers = composeWithDevTools({});

  const composedEnhancers = composeEnhancers(
    applyMiddleware(...middleware)
  );

  const store = createStore(
    rootReducer,
    initialState,
    composedEnhancers
  );

  for (const sagaKey of Object.keys(sagas)) {
    sagaMiddleware.run(sagas[sagaKey]);
  }

  return store;
}
开发者ID:stevejhiggs,项目名称:macgyver,代码行数:25,代码来源:configureStore.ts


示例5: configureStore

export default function configureStore(initialState = {}, history) {
  // Middleware you want to use in production:
  const enhancer = applyMiddleware(
    routerMiddleware(history),
    createSagaMiddleware()
  );

  // Note: only Redux >= 3.1.0 supports passing enhancer as third argument.
  // See https://github.com/rackt/redux/releases/tag/v3.1.0
  const reducer = createReducer();
  return createStore(reducer, initialState, enhancer);
};
开发者ID:bananalabs,项目名称:typescript-starter-react-redux,代码行数:12,代码来源:store.prod.ts


示例6: function

export default function (initialState, ...middlewares) {
  const sagaMiddleware = createSagaMiddleware();
  const store: Store<State> = createStore(
    reducer,
    initialState || {},
    applyMiddleware(
      ...middlewares,
      sagaMiddleware
    )
  );

  sagaMiddleware.run(sagas);

  return store;
}
开发者ID:billba,项目名称:botchat,代码行数:15,代码来源:createStore.ts


示例7: createSagaMiddleware

export default <S extends {}, A extends Action<string>>({
  preloadedState,
  rootReducer,
  rootSaga
}: {
  preloadedState?: object
  rootReducer: Reducer<S, A>
  rootSaga: () => SagaIterator
}): Store<S, A> => {
  const sagaMiddleware = createSagaMiddleware()

  const store = createStore(rootReducer, preloadedState, applyMiddleware(sagaMiddleware))

  sagaMiddleware.run(rootSaga)

  return store
}
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:17,代码来源:configureStore.ts


示例8: configureStore

export default function configureStore(initialState) {
  const sagaMiddleware = createSagaMiddleware()

  const store = createStore(reducers, initialState, compose(
    applyMiddleware(thunk, routerMiddleware(browserHistory),
      translation, sagaMiddleware, errorLogger),
    window.devToolsExtension ? window.devToolsExtension({

      // https://github.com/zalmoxisus/redux-devtools-extension/issues/159
      stateSanitizer: (state) => {
        if (state.Video.player) {
          return { ...state, Video: { ...state.Video, player: "<<PLAYER>>" } }
        }

        return state
      },
      actionsBlacklist: ["VIDEO_PROGRESS"],
    }) : (f) => f))

  sagaMiddleware.run(rootSaga)

  return store
}
开发者ID:nikteg,项目名称:loud,代码行数:23,代码来源:configureStore.ts


示例9: testContext

function testContext() {
  interface Context {
    a: string;
    b: number;
  }

  // typings:expect-error
  createSagaMiddleware<Context>({context: {c: 42}});

  // typings:expect-error
  createSagaMiddleware({context: 42});

  const middleware = createSagaMiddleware<Context>({
    context: {a: '', b: 42},
  });

  // typings:expect-error
  middleware.setContext({c: 42});

  middleware.setContext({b: 42});

  const task = middleware.run(function* () {yield effect});
  task.setContext({b: 42});

  task.setContext<Context>({a: ''});
  // typings:expect-error
  task.setContext<Context>({c: ''});
}
开发者ID:liesislukas,项目名称:redux-saga,代码行数:28,代码来源:middleware.ts


示例10: testOptions

function testOptions() {
  const emptyOptions = createSagaMiddleware({});

  const withOptions = createSagaMiddleware({
    onError(error) {
      console.error(error);
    },

    logger(level, ...args) {
      console.log(level, ...args);
    },

    sagaMonitor: {
      effectTriggered() { },
    },

    emitter: emit => action => {
      if (Array.isArray(action)) {
        action.forEach(emit);
        return
      }
      emit(action);
    },
  });

  const withMonitor = createSagaMiddleware({
    sagaMonitor: {
      effectTriggered() {},
      effectResolved() {},
      effectRejected() {},
      effectCancelled() {},
      actionDispatched() {},
    }
  });
}
开发者ID:liesislukas,项目名称:redux-saga,代码行数:35,代码来源:middleware.ts


示例11: configureStore

export function configureStore() {
    const sagaMiddleware = createSagaMiddleware({
        onError: () => null,
    });

    function runSaga(saga: Effect): Task {
        return sagaMiddleware.run(SagaRunner, saga);
    }

    function runSagaInitialized(saga: any): Task {
        return sagaMiddleware.run(SagaInitialized, saga);
    }

    const store = createStore(
        reducer,
        applyMiddleware(sagaMiddleware)
    );

    (store as any).runSaga = runSaga;
    (store as any).runSagaInitialized = runSagaInitialized;
    (store as any).sagaMiddleware = sagaMiddleware;

    return store as ExtendedStore<typeof store, {
        runSaga: RunSagaEffect;
        runSagaInitialized: RunSagaEffect;
        sagaMiddleware: SagaMiddleware,
    }>;
}
开发者ID:Jyrno42,项目名称:tg-resources,代码行数:28,代码来源:reduxStore.ts


示例12: createSagaMiddleware

const createStore = (initialState?: State): Store<State> => {
  const sagaMiddleware = createSagaMiddleware();
  const enhancer = applyMiddleware(sagaMiddleware);
  const store = create<State>(reducer, initialState, enhancer);
  sagaMiddleware.run(saga);
  return store;
};
开发者ID:bouzuya,项目名称:peggie2,代码行数:7,代码来源:store.ts


示例13: testRun

function testRun() {
  const middleware = createSagaMiddleware()

  middleware.run(function* saga(): SagaIterator {})

  // TODO: https://github.com/Microsoft/TypeScript/issues/28803
  {
    // typings:expect-error
    // middleware.run(function* saga(a: 'a'): SagaIterator {})
  }

  // typings:expect-error
  middleware.run(function* saga(a: 'a'): SagaIterator {}, 1)

  middleware.run(function* saga(a: 'a'): SagaIterator {}, 'a')

  // TODO: https://github.com/Microsoft/TypeScript/issues/28803
  {
    // typings:expect-error
    // middleware.run(function* saga(a: 'a', b: 'b'): SagaIterator {}, 'a')
  }

  // typings:expect-error
  middleware.run(function* saga(a: 'a', b: 'b'): SagaIterator {}, 'a', 1)

  // typings:expect-error
  middleware.run(function* saga(a: 'a', b: 'b'): SagaIterator {}, 1, 'b')

  middleware.run(function* saga(a: 'a', b: 'b'): SagaIterator {}, 'a', 'b')

  // test with any iterator i.e. when generator doesn't always yield Effects.
  middleware.run(function* saga() {
    yield promise
  })
}
开发者ID:rahulrcopart,项目名称:redux-saga,代码行数:35,代码来源:middleware.ts


示例14: createAdminUIStore

export function createAdminUIStore() {
  const sagaMiddleware = createSagaMiddleware();

  const store = createStore(
    combineReducers<AdminUIState>({
      cachedData: apiReducersReducer,
      hover: hoverReducer,
      localSettings: localSettingsReducer,
      metrics: metricsReducer,
      queryManager: queryManagerReducer,
      routing: routerReducer,
      timewindow: timeWindowReducer,
      uiData: uiDataReducer,
    }),
    compose(
      applyMiddleware(thunk, sagaMiddleware),
      // Support for redux dev tools
      // https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd
      (window as any).devToolsExtension ? (window as any).devToolsExtension({
        // TODO(maxlang): implement {,de}serializeAction.
        // TODO(maxlang): implement deserializeState.
        serializeState: (_key: string, value: any): Object => {
          if (value && value.toRaw) {
            return value.toRaw();
          }
          return value;
        },
      }) : _.identity,
    ) as GenericStoreEnhancer,
  );

  sagaMiddleware.run(queryMetricsSaga);
  return store;
}
开发者ID:boreys,项目名称:cockroach,代码行数:34,代码来源:state.ts


示例15: Promise

  return new Promise((resolve, reject) => {
    try {
      const pages = pagesLoaders.map(Page => new Page())

      const initialState = bindInitialState(pages)
      const reducerList = bindReducers(pages)

      const enhancer: any =
        process.env.NODE_ENV === 'development' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
          ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
          : compose
      const sagaMiddleware = createSagaMiddleware()

      const appReducer = combineReducers(reducerList)
      const signOutAction = Actions.SignOut.SIGN_OUT
      const rootReducer = (state: any, action: any) => appReducer(action.type === signOutAction ? {} : state, action)

      const store = createStore(rootReducer, initialState, enhancer(applyMiddleware(sagaMiddleware), autoRehydrate()))

      sagaMiddleware.run(bindSagas(pages))

      persistStore(store, {}, () => resolve({ store, pages }))
    } catch (e) {
      reject(e)
    }
  })
开发者ID:aconly,项目名称:frost-web,代码行数:26,代码来源:store.ts


示例16: createSagaMiddleware

export const init = (state: RootState) => {
  const sagaMiddleware = createSagaMiddleware({});
  const store = createStore(
    rootReducer, state, 
    applyMiddleware(sagaMiddleware)
  );
  sagaMiddleware.run(rootSaga);
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:8,代码来源:index.ts


示例17: createSagaMiddleware

const init = (initialState: ApplicationState) => {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    mainReducer,
    initialState,
    applyMiddleware(sagaMiddleware)
  );
  sagaMiddleware.run(mainSaga);
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:9,代码来源:index.ts


示例18: createSagaMiddleware

const createStore = (): Store<State> => {
  const sagaMiddleware = createSagaMiddleware();
  const store = create<State>(
    reducer,
    applyMiddleware(sagaMiddleware)
  );
  sagaMiddleware.run(saga);
  return store;
};
开发者ID:bouzuya,项目名称:ts-redux-saga-ssr,代码行数:9,代码来源:store.ts


示例19: createMockStore

export function createMockStore(state: IApplicationState): any {
  const sagaMiddleware = createSagaMiddleware()

  const middlewares = [
    sagaMiddleware,
  ]

  const mockStore = configureStore(middlewares)
  const store = mockStore(state)

  sagaMiddleware.run(rootSaga)

  return store
}
开发者ID:goblindegook,项目名称:dictionary-react-redux-typescript,代码行数:14,代码来源:createMockStore.ts


示例20: fork

export const initBaseApplication2 = <TState>(initialState: TState, reducer: Reducer<TState>, mainSaga: () => Iterator<any>, ...middleware: Middleware[]) => {
  const sagaMiddleware = createSagaMiddleware();
  const store = createStore(
    reducer, 
    initialState,
    applyMiddleware(sagaMiddleware, ...middleware)
  );

  sagaMiddleware.run(function*() {
    yield fork(consoleLogSaga);
    yield fork(mainSaga);
  });

  return store;
};
开发者ID:cryptobuks,项目名称:tandem,代码行数:15,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript redux-saga.delay函数代码示例发布时间:2022-05-25
下一篇:
TypeScript redux-saga.channel函数代码示例发布时间: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