<commit_before>import React from 'react';
import { hashHistory } from 'react-router';
import { routerReducer, routerMiddleware, syncHistoryWithStore } from 'react-router-redux';
import cmf from '@talend/react-cmf';
import { getReduceConfig, mergeObjects, getUnique } from '@talend/react-cmf/lib/cmfModule.merge';
import { fork } from 'redux-saga/effects';
import UIRouter from './UIRouter';
import expressions from './expressions';
import sagaRouter from './sagaRouter';
import * as selectors from './selectors';
import documentTitle from './sagas/documentTitle';
import cmfRouterMiddleware from './middleware';
import { REGISTRY_HOOK_PREFIX } from './route';

const mergeConfig = {
	history: getUnique,
	sagaRouterConfig: mergeObjects,
	routerFunctions: mergeObjects,
};

function mergeRouterConfig(...configs) {
	return configs.reduce(getReduceConfig(mergeConfig), {});
}

function getModule(...args) {
	const options = mergeRouterConfig(...args);
	const history = options.history || hashHistory;
	const registry = {};
	if (options.routerFunctions) {
		Object.keys(options.routerFunctions).reduce((acc, key) => {
			// eslint-disable-next-line no-param-reassign
			acc[`${REGISTRY_HOOK_PREFIX}:${key}`] = options.routerFunctions[key];
			return acc;
		}, registry);
	}
	function* saga() {
		yield fork(documentTitle);
		if (options.sagaRouterConfig) {
			yield fork(sagaRouter, history, options.sagaRouterConfig);<commit_msg>feat(TMC-20092): provide possibility to start router after specified action (#2654)<commit_after>import React from 'react';
import { hashHistory } from 'react-router';
import { routerReducer, routerMiddleware, syncHistoryWithStore } from 'react-router-redux';
import cmf from '@talend/react-cmf';
import { getReduceConfig, mergeObjects, getUnique } from '@talend/react-cmf/lib/cmfModule.merge';
import { fork, takeLatest } from 'redux-saga/effects';
import UIRouter from './UIRouter';
import expressions from './expressions';
import sagaRouter from './sagaRouter';
import * as selectors from './selectors';
import documentTitle from './sagas/documentTitle';
import cmfRouterMiddleware from './middleware';
import { REGISTRY_HOOK_PREFIX } from './route';

const mergeConfig = {
	history: getUnique,
	sagaRouterConfig: mergeObjects,
	routerFunctions: mergeObjects,
	startOnAction: getUnique,
};

function mergeRouterConfig(...configs) {
	return configs.reduce(getReduceConfig(mergeConfig), {});
}

function getModule(...args) {
	const options = mergeRouterConfig(...args);
	const history = options.history || hashHistory;
	const registry = {};
	if (options.routerFunctions) {
		Object.keys(options.routerFunctions).reduce((acc, key) => {
			// eslint-disable-next-line no-param-reassign
			acc[`${REGISTRY_HOOK_PREFIX}:${key}`] = options.routerFunctions[key];
			return acc;
		}, registry);
	}

	function* saga() {
		let routerStarted = false;
		yield fork(documentTitle);
		if (options.sagaRouterConfig) {
			if (options.startOnAction) {
				yield takeLatest(options.startOnAction, function* startRouter() {
					if (!routerStarted) {
						yield fork(sagaRouter, history, options.sagaRouterConfig);
						routerStarted = true;
					}
				});
			} else {
				yield fork(sagaRouter, history, options.sagaRouterConfig);
			}
{'fraction_non_alphanumeric': 0.1336206896551724, 'fraction_numerical': 0.002770935960591133, 'mean_word_length': 5.2122370936902485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2857852', 'n_tokens_mistral': 1058, 'n_tokens_neox': 981, 'n_words': 231}