{"size": 1272, "ext": "js", "max_stars_repo_path": "shared/store/configure-sagas.js", "max_stars_repo_name": "warner/keybase-client", "max_stars_repo_stars_event_min_datetime": "2017-03-10T17:53:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-10T17:53:37.000Z", "max_issues_repo_path": "shared/store/configure-sagas.js", "max_issues_repo_name": "warner/keybase-client", "max_issues_repo_issues_event_min_datetime": "2021-05-09T11:02:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-10T18:57:58.000Z", "max_forks_repo_path": "shared/store/configure-sagas.js", "max_forks_repo_name": "MichaelAquilina/client", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 24.9411764706, "max_line_length": 60, "alphanum_fraction": 0.7177672956}
// @flow
import chatSaga from '../actions/chat'
import createSagaMiddleware from 'redux-saga'
import deviceSaga from '../actions/devices'
import favoriteSaga from '../actions/favorite'
import gregorSaga from '../actions/gregor'
import kbfsSaga from '../actions/kbfs'
import notificationsSaga from '../actions/notifications'
import pgpSaga from '../actions/pgp'
import planBillingSaga from '../actions/plan-billing'
import profileSaga from '../actions/profile'
import settingsSaga from '../actions/settings'
import pushSaga from '../actions/push'
import {call} from 'redux-saga/effects'

import type {SagaGenerator} from '../constants/types/saga'

function * mainSaga (): SagaGenerator<any, any> {
  yield [
    call(chatSaga),
    call(deviceSaga),
    call(favoriteSaga),
    call(gregorSaga),
    call(kbfsSaga),
    call(notificationsSaga),
    call(pgpSaga),
    call(planBillingSaga),
    call(profileSaga),
    call(pushSaga),
    call(settingsSaga),
  ]
}

let middleWare
function create (crashHandler: (err: any) => void) {
  if (middleWare) {
    throw new Error('Only create one saga middleware!')
  }
  middleWare = createSagaMiddleware({onError: crashHandler})
  return middleWare
}

function run () {
  middleWare.run(mainSaga)
}

export {
  create,
  run,
}
