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


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

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


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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: createSagaMiddleware

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


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