Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
merge prefilledState with defaultState in reducers on redux-specific …
Browse files Browse the repository at this point in the history
…actions
  • Loading branch information
NikitaKolokoltsev committed Dec 11, 2018
1 parent f8abcb9 commit 2f9afe6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/redux-subspace/src/actions/processAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import hasNamespace from '../actions/hasNamespace'
import isGlobal from '../actions/isGlobal'
import isReduxSpecific from '../actions/reduxSpecific'

const processAction = (namespace) => (action, callback, defaultValue) => {
if (!namespace || isGlobal(action)) {
if (!namespace || isGlobal(action) || isReduxSpecific(action)) {
return callback(action)
} else if (hasNamespace(action, namespace)) {
return callback({...action, type: action.type.substring(namespace.length + 1)})
Expand Down
13 changes: 13 additions & 0 deletions packages/redux-subspace/src/actions/reduxSpecific.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright 2017, IOOF Holdings Limited.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const REDUX_PREFIX = '@@redux/'

const reduxSpecific = (action) => action.type.startsWith(REDUX_PREFIX)

export default reduxSpecific
4 changes: 1 addition & 3 deletions packages/redux-subspace/src/reducers/namespaced.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export default (namespace) => {
return reducer(state, action)
}

const defaultState = reducer(state, action)

return actionProcessor(action, (transformedAction) => reducer(state, transformedAction), defaultState)
return actionProcessor(action, (transformedAction) => reducer(state, transformedAction), state)
}
}

0 comments on commit 2f9afe6

Please sign in to comment.