當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。