Created
July 13, 2017 17:51
-
-
Save atticoos/1f7b3fe1cc8f4eadfa580e9593d56537 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'use strict'; | |
import * as Reselect from 'reselect'; | |
export function createSelector (...args) { | |
const selector = Reselect.createSelector(...args); | |
var debug = false; | |
var debugLabel = null; | |
function debuggableSelector (...selectorArgs) { | |
if (!__DEV__ || !debug) { | |
return selector(...selectorArgs); | |
} | |
const out = selector(...selectorArgs); | |
console.groupCollapsed( | |
'Selector' + (debugLabel ? ` - ${debugLabel}` : '') | |
); | |
console.info(out); | |
console.groupEnd(); | |
return out; | |
} | |
debuggableSelector.debug = (label) => { | |
debug = true; | |
debugLabel = label; | |
return debuggableSelector; | |
}; | |
return debuggableSelector; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before:
After: