function* sagaRouter(history, routes) {
	const sagas = {};
	const routeFragments = Object.keys(routes);
	while (true) {
		const shouldStart = [];
		const currentLocation = history.getCurrentLocation();
		for (let index = 0; index < routeFragments.length; ) {
			const routeFragment = routeFragments[index];
			const routeSaga = routes[routeFragment];
			const { match, maybeSaga } = parseSagaState(routeFragment, sagas, currentLocation);
			if (shouldCancelSaga(maybeSaga, match, routeSaga)) {
				yield cancel(maybeSaga.saga);
			} else if (shouldRestartSaga(maybeSaga, match, routeSaga)) {
				yield cancel(maybeSaga.saga);
				shouldStart.push({ routeFragment, match });
			} else if (shouldStartSaga(maybeSaga, match, routeSaga)) {
				shouldStart.push({ routeFragment, match });
			}
			index += 1;
		}
		for (let index = 0; index < shouldStart.length; ) {
			const { routeFragment, match } = shouldStart[index];
			let routeSaga = routes[routeFragment];
			if (typeof routes[routeFragment] === 'object') {
				routeSaga = routes[routeFragment].saga;
			}
			sagas[routeFragment] = {
				saga: yield spawn(routeSaga, match.params, match.isExact),
				match,
			};
			index += 1;
		}
		// eslint-disable-line no-constant-condition
		yield take('@@router/LOCATION_CHANGE');
	}
}
/**
 * responsible to start and cancel saga based on application current url,
 * restart saga if necessary
 * @param {object} history - react router history
 * @param {RoutesConfig} routes
 */
responsible to start and cancel saga based on application current url,
restart saga if necessary
@param {object} history - react router history
@param {RoutesConfig} routes
responsible to start and cancel saga based on application current url restart saga if necessary @param { object } history - react router history @param { RoutesConfig } routes
function* sagaRouter(history, routes) {
	const sagas = {};
	const routeFragments = Object.keys(routes);
	while (true) {
		const shouldStart = [];
		const currentLocation = history.getCurrentLocation();
		for (let index = 0; index < routeFragments.length; ) {
			const routeFragment = routeFragments[index];
			const routeSaga = routes[routeFragment];
			const { match, maybeSaga } = parseSagaState(routeFragment, sagas, currentLocation);
			if (shouldCancelSaga(maybeSaga, match, routeSaga)) {
				yield cancel(maybeSaga.saga);
			} else if (shouldRestartSaga(maybeSaga, match, routeSaga)) {
				yield cancel(maybeSaga.saga);
				shouldStart.push({ routeFragment, match });
			} else if (shouldStartSaga(maybeSaga, match, routeSaga)) {
				shouldStart.push({ routeFragment, match });
			}
			index += 1;
		}
		for (let index = 0; index < shouldStart.length; ) {
			const { routeFragment, match } = shouldStart[index];
			let routeSaga = routes[routeFragment];
			if (typeof routes[routeFragment] === 'object') {
				routeSaga = routes[routeFragment].saga;
			}
			sagas[routeFragment] = {
				saga: yield spawn(routeSaga, match.params, match.isExact),
				match,
			};
			index += 1;
		}
		yield take('@@router/LOCATION_CHANGE');
	}
}
function * sagaRouter ( history , routes ) { const sagas = { } ; const routeFragments = Object . keys ( routes ) ; while ( true ) { const shouldStart = [ ] ; const currentLocation = history . getCurrentLocation ( ) ; for ( let index = 0 ; index < routeFragments . length ; ) { const routeFragment = routeFragments [ index ] ; const routeSaga = routes [ routeFragment ] ; const { match , maybeSaga } = parseSagaState ( routeFragment , sagas , currentLocation ) ; if ( shouldCancelSaga ( maybeSaga , match , routeSaga ) ) { yield cancel ( maybeSaga . saga ) ; } else if ( shouldRestartSaga ( maybeSaga , match , routeSaga ) ) { yield cancel ( maybeSaga . saga ) ; shouldStart . push ( { routeFragment , match } ) ; } else if ( shouldStartSaga ( maybeSaga , match , routeSaga ) ) { shouldStart . push ( { routeFragment , match } ) ; } index += 1 ; } for ( let index = 0 ; index < shouldStart . length ; ) { const { routeFragment , match } = shouldStart [ index ] ; let routeSaga = routes [ routeFragment ] ; if ( typeof routes [ routeFragment ] === 'object' ) { routeSaga = routes [ routeFragment ] . saga ; } sagas [ routeFragment ] = { saga : yield spawn ( routeSaga , match . params , match . isExact ) , match , } ; index += 1 ; } yield take ( '@@router/LOCATION_CHANGE' ) ; } }
responsible to start and cancel saga based on application current url,
 restart saga if necessary
 @param {object} history - react router history
 @param {RoutesConfig} routes
responsible to start and cancel saga based on application current url restart saga if necessary @param { object } history - react router history @param { RoutesConfig } routes
// eslint-disable-line no-constant-condition