-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add a possibility to delete all reselect selectors stored in the cache under a specific key pattern #40
Comments
Hi @gawlk ! It could be a viable option for a next release. We might consider to expose a getter as you suggest or simply expose the cache object as a property: selector.getCache(); // as getter
selector.cache; // as property In the meanwhile there is another solution to let you not use a patched version of From version 1 you can provide a custom
import {FlatObjectCache} from 're-reselect';
export class CustomFlatObjectCache extends FlatObjectCache {
superCacheDeletion() {
//...
}
}
import createCachedSelector from 're-reselect';
import CustomFlatObjectCache from './CustomFlatObjectCache';
const myCacheObjectInstance = new CustomFlatObjectCache();
const mySelector = createCachedSelector(
// ...
)(
resolverFunction,
{
cacheObject: myCacheObjectInstance,
}
);
myCacheObjectInstance.superCacheDeletion('foo'); Could it work in your use case? Greetings! |
That's great, both exposing a getter or the cache object as a property would work for me ! I'll your try your temporary solution and I'll let you know ! But from the looks of it, it should work. Thank you very much ! EDIT: It works ! Should I close the issue or wait until you release the next version (with the getter) ? |
Glad to hear that! Greetings! |
Shipped! v2.1.0 🎉 |
Hi,
I have a problem with the way we can remove selectors from a cache object.
For example, in my code, the keys under which my selectors are stored, are generated using a function and are following a specific pattern (number(:number)*). I would like to remove from the cache every selector stored under a key starting with a "1".
The problem is, that I cannot use
selector.getMatchingSelector
because it uses theresolver
instead of directly checking if_cache
has a selector stored under a specific string.I found a way to counter that by adding this function to the
createCachedSelector
function:and by removing manually in my code every selector stored under a key starting with a "1".
But it would be much cleaner if something similar was implemented directly in your cache objects.
So my question is the next, would it be possible to add a function which removes all the selectors of a cache object that are stored under a specific key pattern ?
If not, could you at least add a function to
createCachedSelector
which allows us to get the_cache
of a cache object (like the one I had to add).Feel free to let me know, if I'm not being clear enough !
The text was updated successfully, but these errors were encountered: