Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
Remove INIT_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjoar committed Dec 12, 2015
1 parent d2b2d3c commit 2ed7ad8
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,11 @@ const deepEqual = require('deep-equal')

// Constants

const INIT_PATH = '@@router/INIT_PATH'
const UPDATE_PATH = '@@router/UPDATE_PATH'
const SELECT_STATE = state => state.routing
const UPDATE_PATH = "@@router/UPDATE_PATH";
const SELECT_STATE = state => state.routing;

// Action creators

function initPath(path, state) {
return {
type: INIT_PATH,
payload: {
path: path,
state: state,
replace: false,
avoidRouterUpdate: true
}
}
}

function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
return {
type: UPDATE_PATH,
Expand Down Expand Up @@ -54,7 +41,7 @@ let initialState = {
}

function update(state=initialState, { type, payload }) {
if(type === INIT_PATH || type === UPDATE_PATH) {
if(type === UPDATE_PATH) {
return Object.assign({}, state, {
path: payload.path,
changeId: state.changeId + (payload.avoidRouterUpdate ? 0 : 1),
Expand Down Expand Up @@ -128,7 +115,8 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
// trigger an unnecessary `pushState` on load
lastRoute = initialState

store.dispatch(initPath(route.path, route.state))
const method = location.action === 'REPLACE' ? replacePath : pushPath;
store.dispatch(method(route.path, route.state, { avoidRouterUpdate: true }));
} else if(!locationsAreEqual(getRouterState(), route)) {
// The above check avoids dispatching an action if the store is
// already up-to-date
Expand Down

0 comments on commit 2ed7ad8

Please sign in to comment.