-
Notifications
You must be signed in to change notification settings - Fork 24
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support groups of selectors #15
Comments
Hey @anikolaev I think I have a solution for your problem! The key here is that when you do console.log(auditsSelector);
// { 'selectedAudit': selectedAuditFunc } Since this is just a plain javascript object, you can do namespacing pretty easily: const namespaceSelectors = (selectors, prefix) => {
const namespaced = {};
Object.entries(selectors).forEach(([name, func]) => {
namespaced[`${prefix}:${name}`] = func;
});
return namespaced;
}; Usage would be like so: import * as auditsSelectors from 'selectors/audits'
ReselectTools.registerSelectors(
namespaceSelectors(auditsSelectors, 'audits')
); Try that out and let me know if it helps! Thanks, |
Yes, I thought about that but they would still be displayed as flat nodes in a single line as I showed in my screenshot. So I will have to move nodes every time to make them readable. And there are just 4 of 27 groups shown. It will be a mess with all selectors shown. So I think it is better to add support of this functionality to lib and extensions and visualize groups of selectors somehow. |
@anikolaev why do you think they would be displayed as flat nodes? Did you try it out? From a cursory glance it looks like it ought to "just work" since the |
I am creating a copy here as it needs to be fixed in both lib and extension.
There are 27 files in my selectors folder and they share selector names like
id
so it is always useless to see a flat structure. Here is the picture after registering only 4 of 27 files:Here is a typical structure of my files containing selectors and how I register them. Maybe I am doing something wrong.
selectors/accessTokens.js
selectors/entities.js
selectors/audits.js
...
selectors/index.js
store.js
I think there should be a way to add selectors specifying the name it their groups like 'audits', 'entities' etc. In the code they are imported as
so it will be clear for developers.
The text was updated successfully, but these errors were encountered: