diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 1a72e80..6c3a492 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -1,5 +1,8 @@ import { ReducersMapObject } from 'redux'; +import { SagaWatcher } from '@overflow/commons/redux-saga'; + import signInReducer from '@overflow/member/redux/reducer/signIn'; +import signInSagaWatchers from '@overflow/member/redux/saga/signIn'; // Container Configuration export interface ContainerConfig { @@ -21,17 +24,23 @@ const rpcConfig: RPCConfig = { export interface ReduxConfig { state: ReduxState; reducerMaps: ReducersMapObject[]; + sagaWarchers: (SagaWatcher[])[]; } export interface ReduxState { } const reduxState: ReduxState = {}; + + const reduxConfig: ReduxConfig = { state: reduxState, reducerMaps: [ signInReducer, ], + sagaWarchers: [ + signInSagaWatchers, + ], }; diff --git a/src/ts/@overflow/app/index.tsx b/src/ts/@overflow/app/index.tsx index 94b9c70..fefe874 100644 --- a/src/ts/@overflow/app/index.tsx +++ b/src/ts/@overflow/app/index.tsx @@ -20,8 +20,15 @@ import { import createSagaMiddleware, { SagaMiddleware, + SagaIterator, } from 'redux-saga'; +import { + fork, +} from 'redux-saga/effects'; + + + import { createHashHistory, History, @@ -39,12 +46,10 @@ import AppContext from '@overflow/commons/context'; import * as AppContextLifecycleActions from '@overflow/commons/context/redux/action/lifecycle'; import WebSocketRPC from '@overflow/commons/websocket/WebSocketRPC'; import ReducerContext from '@overflow/commons/redux/ReducerContext'; +import { SagaWatcher } from '@overflow/commons/redux-saga'; import appConfig, { Config, ReduxState } from './config'; -import sagas from './redux/saga'; -// import routes from './router'; - import App from './views/App'; injectTapEventPlugin(); @@ -82,6 +87,7 @@ class Application { this.context = await this.initContext(); // this.rpcClient = await this.initRpcClient(); + // this.context.put(this.rpcClient); await this.initRedux(); @@ -141,13 +147,21 @@ class Application { Application.useReduxDevTools ? compose(middleware, window.devToolsExtension()) : middleware, ); // saga - this.sagaMiddleware.run(sagas); + this.sagaMiddleware.run(this.initReduxSagaWarchers, this.config.redux.sagaWarchers); resolve(); }); return init; } + private * initReduxSagaWarchers(sagaWarchers: (SagaWatcher[])[]): SagaIterator { + for (let sagaWarcher of sagaWarchers) { + for (let warcher of sagaWarcher) { + yield fork(warcher); + } + } + } + private displayLoading(): void { ReactDOM.render(