Skip to content

Instantly share code, notes, and snippets.

@marr
Created March 8, 2017 19:03
Show Gist options
  • Save marr/18a8bdf89ca9aca67834f81bdd908e63 to your computer and use it in GitHub Desktop.
Save marr/18a8bdf89ca9aca67834f81bdd908e63 to your computer and use it in GitHub Desktop.
import { call, spawn } from 'redux-saga/effects'
import { sagas as centreSagas } from './ducks/centres'
export default async function rootSaga() {
const sagas = [...centreSagas]
await sagas.map(saga =>
spawn(async function () {
console.log(saga);
let isSyncError = false
while (!isSyncError) {
isSyncError = true
try {
setTimeout(() => { isSyncError = false })
await call(saga)
} catch (e) {
if (isSyncError) {
throw new Error(saga.name + ' was terminated because it threw an exception on startup.')
}
// handle exceptions here
}
}
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment