-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Better documentation for resolvers? #53
Comments
@seanohollaren Firstly, sorry for replying that late, Github notifications failed for me, and it's today I noticed that issue.
Now concerning normalization of cache id, there's not documented option Through that option you provide a function that's meant to resolve cache id (string) for given call. So in case you're describing it can be: var memoizedFunction = memoizee(function (anObject, aBool) {
...
}, { normalizer: function (args) {
var anObject = args[0], aBool = args[1];
return anObject.id + aBool.toString();
}); |
Fixed by 75422fd |
Looks great, thanks! |
I'm a huge fan of the built-in stats and cache management tools that memoizee offers, but right now I'm totally puzzled by how I'm supposed to use the resolver functionality.
Lodash and Underscore resolvers are very straight forward. For those, you provide a function which returns the key used for the cache map.
Like this:
const memoizedFunction = _.memoize(nonMemoizedFunction, (anObject, aBool) => anObject.id + aBool.toString() );
Memoizee's resolver functionality, however, is a lot less clear.
To me, it's not apparent from the documentation how to craft a resolver function and it seems that memoizee focuses on argument type as opposed to allowing for arbitrary key construction.
Is it possible to memoize based on a given object's property instead of attempting to serialize the entire object? What about combining that with a second parameter?
For example, given
foo(anObject, aBool)
, I'd like my memoization key to beanObject.id + bool
.Given how important resolvers are to a memoization library functioning as intended, I think the documentation would really benefit from being beefed up with useful examples as opposed to trivial ones.
The text was updated successfully, but these errors were encountered: