UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

6 lines 633 B
import{historyPop}from"./historyPop";import{historyReplace}from"./historyReplace";/** * Performs a redirect. When the action params contain a location, the current history entry * will be replaced with it. Otherwise the current history entry will be popped. * @param {Object} params The redirect params. * @return {Function} A redux thunk. */export function historyRedirect(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var location=params.location,state=params.state;if(!location){dispatch(historyPop());return;}dispatch(historyReplace({pathname:location,state:state}));};}