import { ActionType , createAction } from '@ulangi/ulangi-action' ; import { fork , put , take } from 'redux-saga/effects' ; import { PublicSaga } from './PublicSaga' ; export class AppSaga extends PublicSaga { public * run ( ) { yield fork ( [ this , this . allowInitialize ] ) ; } public * allowInitialize ( ) { yield take ( ActionType . APP__INITIALIZE ) ; yield put ( createAction ( ActionType . APP__INITIALIZING , null ) ) ; yield put ( createAction ( ActionType . NETWORK__CHECK_CONNECTION , null ) ) ; yield put ( createAction ( ActionType . NETWORK__OBSERVE_CONNECTION_CHANGE , null ) ) ; yield put ( createAction ( ActionType . DATABASE__CONNECT_SHARED_DB , null ) ) ; yield take ( [ ActionType . DATABASE__CONNECT_SHARED_DB_SUCCEEDED , ActionType . DATABASE__ALREADY_CONNECTED_SHARED_DB , ] ) ; yield put ( createAction ( ActionType . DATABASE__CHECK_SHARED_DB , null ) ) ; yield take ( [ ActionType . DATABASE__CHECK_SHARED_DB_SUCCEEDED , ActionType . DATABASE__ALREADY_CHECKED_SHARED_DB , ] ) ; yield put ( createAction ( ActionType . APP__INITIALIZE_SUCCEEDED , null ) ) ; while ( true ) { yield take ( ActionType . APP__INITIALIZE ) ; yield put ( createAction ( ActionType . APP__ALREADY_INITIALIZED , null ) ) ; } } }