-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thomas Dashney
committed
Jun 27, 2018
1 parent
71821d0
commit acaf5ea
Showing
5 changed files
with
48 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import get from 'lodash.get' | ||
import warning from 'warning' | ||
import createActions from './create-actions' | ||
import mountActions from './mount-actions' | ||
|
||
export default function mount (pathToState, logic) { | ||
warning(true, 'redux-modular mount() is deprecated') | ||
validateArgs(...arguments) | ||
return mountLogic(pathToState, logic) | ||
} | ||
|
||
function validateArgs (pathToState, logic) { | ||
if (!logic) { | ||
throw new Error('logic must be passed to mount') | ||
} | ||
} | ||
|
||
function mountLogic (pathToState, logic) { | ||
const result = {} | ||
|
||
if (logic.actions) { | ||
result.actions = createAndMountActions(pathToState, logic.actions) | ||
} | ||
|
||
if (logic.actions && logic.reducer) { | ||
result.reducer = logic.reducer(result.actions) | ||
} | ||
|
||
if (logic.selectors) { | ||
createSelectors(pathToState, logic.selectors) | ||
} | ||
|
||
return result | ||
} | ||
|
||
function createAndMountActions (pathToState, actions) { | ||
return mountActions(pathToState, createActions(actions)) | ||
} | ||
|
||
function createSelectors (pathToState, selectors) { | ||
const localStateSelector = pathToState | ||
? state => get(state, pathToState) | ||
: state => state | ||
|
||
return selectors(localStateSelector) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.