New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Rename devToolsExtension to something more explicit #99
Conversation
ae6326b
to
36f1263
Compare
Will come back to this after reduxjs/redux#1702. Anyway I'd prefer to just add an alias to Thanks for contributing, I appreciate it a lot, and sorry for taking it so long! |
Any reason it couldn't be just
|
So, we could use: let store = createStore(reducer, window.__REDUX_DEVTOOLS_ENHANCER__); instead of let store = createStore(reducer, window.devToolsExtension && window.devToolsExtension()); and let store = createStore(reducer, initialState, compose(
applyMiddleware(...middleware),
window.__REDUX_DEVTOOLS_ENHANCER__ || f => f
)); instead of let store = createStore(reducer, initialState, compose(
applyMiddleware(...middleware),
window.devToolsExtension ? window.devToolsExtension() : f => f
)); On one hand, Since the purpose of this PR cannot be achieved without zalmoxisus/redux-devtools-instrument#1 and reduxjs/redux#1702, I'd open it for discussions and suggestions. |
Is Redux still a dependency either way? If so,
Given that a rename will probably happen, how about: createStore(reducer, window.reduxDevToolsExtension); And: createStore(reducer, window.reduxDevToolsExtension && window.reduxDevToolsExtension.configure(...)); This is what my code currenlty looks like: export default function configureStore(initialState) {
if (process.env.NODE_ENV === "production") {
return createStore(rootReducer, initialState);
} else {
const devTools = window.devToolsExtension && window.devToolsExtension();
const store = createStore(rootReducer, initialState, devTools);
if (module.hot) {
module.hot.accept("../reducers", () =>
store.replaceReducer(require("../reducers").default)
);
}
return store;
}
} Which ends up being compiled to this because of webpack for production code: export default function configureStore(initialState) {
return createStore(rootReducer, initialState);
} The const store = (window.devToolsExtension ?
window.devToolsExtension()(createStore) : createStore
)(rootReducer, initialState); |
It looks like a super-global. And constants may have non-primitive values as well, so this is a constant global enhancer (pre-created for you with the default options). There might be another constant next to it,
|
Please do not pollute the global namespace with more entities than absolutely required, or name them in a globally unique fashion. |
Implemented. Closing in favour of #220. |
The first qualification for #1675, making the name
window.devToolsExtension
less general and more explicit. I chose__REDUX_DEVTOOLS_EXTENSION__
because that's the name of this package over__REDUX_DEVTOOLS_ENHANCER__
or something else because the object contains a few extra important methods likeopen()
. The namewindow.devToolsExtension
was deprecated instead of removed altogether. If someone tries to use it, they will get a warning but it will work as before.I'm afraid I don't know how to test if this doesn't break things 馃槓