Skip to content

Commit

Permalink
clarify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed Mar 6, 2019
1 parent 1a588ee commit b089514
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/data/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import EquivalentKeyMap from 'equivalent-key-map';
import { onSubKey } from './utils';

/**
* Reducer function returning next state for selector resolution, object form:
* Reducer function returning next state for selector resolution of
* subkeys, object form:
*
* reducerKey -> selectorName -> EquivalentKeyMap<Array,boolean>
*
Expand All @@ -19,7 +20,7 @@ import { onSubKey } from './utils';
*
* @returns {Object} Next state.
*/
const isResolved = flowRight( [
const subKeysIsResolved = flowRight( [
onSubKey( 'reducerKey' ),
onSubKey( 'selectorName' ),
] )( ( state = new EquivalentKeyMap(), action ) => {
Expand Down Expand Up @@ -50,7 +51,7 @@ const isResolved = flowRight( [
*
* @return {Object} Next state.
*/
const topLevelIsResolved = ( state = {}, action ) => {
const isResolved = ( state = {}, action ) => {
switch ( action.type ) {
case 'INVALIDATE_RESOLUTION_FOR_STORE':
return has( state, action.reducerKey ) ?
Expand All @@ -66,8 +67,12 @@ const topLevelIsResolved = ( state = {}, action ) => {
),
} :
state;
case 'START_RESOLUTION':
case 'FINISH_RESOLUTION':
case 'INVALIDATE_RESOLUTION':
return subKeysIsResolved( state, action );
}
return isResolved( state, action );
return state;
};

export default topLevelIsResolved;
export default isResolved;

0 comments on commit b089514

Please sign in to comment.