<commit_before>import actionTypes from './actionTypes';
import * as actions from './actions';

function routerPlugin(dispatch) {
    const plugin = {
        name: 'REDUX_PLUGIN',
        onTransitionStart(toState, fromState) {
            dispatch(actions.transitionStart(toState, fromState));
        },
        onTransitionSuccess(toState, fromState) {
            dispatch(actions.transitionSuccess(toState, fromState));
        },
        onTransitionError(toState, fromState, err) {
            dispatch(actions.transitionError(toState, fromState, err));
        }
    };

    return plugin;
}

export default function replaceRoutesMiddleware(router) {
    return ({ dispatch }) => {
        router.usePlugin(routerPlugin(dispatch));

        return next => action => {
            if (action.type === actionTypes.NAVIGATE_TO) {
                router.navigate(action.name, action.params, action.options);
            } else if (action.type === actionTypes.CANCEL_TRANSITION) {
                router.cancel();
            }

            return next(action);
        };
    };
}<commit_msg>feat: add store as an additional argument to router canActivate and canDeactivate functions<commit_after>import actionTypes from './actionTypes';
import * as actions from './actions';

function routerPlugin(dispatch) {
    const plugin = {
        name: 'REDUX_PLUGIN',
        onTransitionStart(toState, fromState) {
            dispatch(actions.transitionStart(toState, fromState));
        },
        onTransitionSuccess(toState, fromState) {
            dispatch(actions.transitionSuccess(toState, fromState));
        },
        onTransitionError(toState, fromState, err) {
            dispatch(actions.transitionError(toState, fromState, err));
        }
    };

    return plugin;
}

export default function replaceRoutesMiddleware(router) {
    return store => {
        const { dispatch } = store;
        router.setAdditionalArgs(store);
        router.usePlugin(routerPlugin(dispatch));


        return next => action => {
            if (action.type === actionTypes.NAVIGATE_TO) {
                router.navigate(action.name, action.params, action.options);
            } else if (action.type === actionTypes.CANCEL_TRANSITION) {
                router.cancel();
            }

            return next(action);
        };
    };
}
{'fraction_non_alphanumeric': 0.11073108165882856, 'fraction_numerical': 0.0, 'mean_word_length': 2.4615384615384617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1978409', 'n_tokens_mistral': 615, 'n_tokens_neox': 603, 'n_words': 124}