Comments (4)
Hey @bdurrer - I don't use re-reselect in my own apps, so I never thought about this use case. However, if you can come up with a way to get it to work I'd be happy to take a PR
from reselect-tools.
Is this just an issue with re-reselect support, or is it an issue with any multi-arity selector? In src/index.js#checkSelector
every selector is executed with the result of stateGetter
, and off the top of my head I can't think of any easy way to provide a default ...rest
parameter for each selector. I always use a second props
object parameter, which I think is a pretty common pattern (any other parameter type can't be composed), so you could possibly have an optional second parameter for registerSelectors
with a default props
object. However, you would need to provide it with a key and value for every selector in the tree, which would be enormous for any non-trivial application. You could alternatively require an additional defaultProps
value for each multi-parameter function, but this just splits up the same amount of work. I don't see any reasonable way to implement this feature that wouldn't require an extensive integration effort.
So in summary:
- A
defaultProps
parameter toregisterSelectors
would require a key-value pair for every unique key used in the application. This would also result in the same key-value pair being used for every selector that consumes that key, which may not work. - Adding a
defaultProps
value or a default parameter value for each "props" selector (i.e.(__, props = { prop: 1 }) => props.prop
) to every multi-arity selector would allow you to specify the default props individually, but would require even more work than the singledefaultProps
parameter toregisterSelectors
from reselect-tools.
Thanks for the info! You're correct that it's probably more a consequence of the second argument - I've never had to use that myself since I tend to think of selectors more as a mechanism for holding whole-app computed state.
from reselect-tools.
Maybe displaying all cached re-reselectors is not practicable anyway. I guess it could also have a negative impact on performance.
At least in our setup, there are only a handful of possible cach entries (each app tab has it's own selector cache entry) and it would already be nice to view one or two variants of each re-reselectors.
How about having a second parameter on registerSelectors
, which allows to provides a function for each selector. It's job would be to calculate the arguments for one selector, similar to what getStateWith
does for the state.
The function would simply return the required input for one of the cached re-reselectors. One could easily make that function dynamically switch caches based on some extern data, e.g. a global cache-key variable, so you can browse through the selectors based on an external controller.
e.g. something like
function selectorArgs(state, selectorName) {
if (reasons) {
return ['param1', 'param2']
} else {
return ['param3', 'param4']
}
}
registerSelectors({ mySelector }, { mySelector: selectorArgs })
would then call the selector like this
const state = _getState()
const selectorArgs = _allSelectorsArgs[selectorName]
const args = selectorArgs ? selectorArgs(state, selectorName) : []
extra.output = selector(state , ...args)
from reselect-tools.
Related Issues (20)
- Instrument on Demand
- Support for iframes HOT 2
- Can't open dev tools window HOT 5
- Combine extension and library repos HOT 3
- Support groups of selectors HOT 2
- Feature Request: Reset "Recomputations" Count HOT 2
- `ReselectTools.registerSelectors()` fails if the given object has a null value property HOT 2
- Support Immutable values HOT 11
- Graph is incorrect. There are no arrows on the graph. HOT 3
- Request to update repository with version 0.0.2 from Chrome App Store HOT 5
- support for typescript
- Graph is missing. No edges HOT 5
- Crashes chrome profiler
- Absent Reselect panel in Chrome HOT 2
- Add selector computation timings to JSON output
- How to graph selector factories?
- Reselect Debugger for React Native Flipper
- Extension marked as malware by Google
- Chrome Extensions devtool link is broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reselect-tools.