You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation unclear of how the memoizer is used #455
The README describes how createSelectorCreator can be used to override the defaultMemoizer and how it will be called with the resultFunc and additional memoizeOptions. However, if my reading of the source code is correct, it's also called before calling the input functions to short-circuit their evaluation, and that isn't called with the memoizeOptions. These are important details for implementing a custom memoizer, so it seems like an oversight in the documentation.
Reacted by Steve Rubin, Timothy Lee and Tony Gentilcore
This bit me recently. I'd appreciate being able to specify a different memoize function for the two purposes. I guess I could do this using memoizeOptions:
I ended up with this slightly more fleshed-out version:
typeMemoizeFn=(func: Function,option1?: any,option2?: any,option3?: any)=>any;exportfunctionmyCreateSelectorCreator(memoizeResultFnArgs: MemoizeFn,memoizeResultFnArgsOptions: any[]=[],memoizeInputFnArgs: MemoizeFn=defaultMemoize,memoizeInputFnArgsOptions: any[]=[],){functionmemoize(fn: Function,areResultArgs: boolean){if(areResultArgs){returnmemoizeResultFnArgs(fn, ...memoizeResultFnArgsOptions);}returnmemoizeInputFnArgs(fn, ...memoizeInputFnArgsOptions);}returncreateSelectorCreator(memoize,true,// only passed to `memoize` for result args, not input args);}
Activity
srubin commentedon Jun 24, 2020
This bit me recently. I'd appreciate being able to specify a different memoize function for the two purposes. I guess I could do this using
memoizeOptions:but it might be cleaner to allow passing a second memoize function to
createSelectorCreator.srubin commentedon Jun 24, 2020
I ended up with this slightly more fleshed-out version:
markerikson commentedon Oct 20, 2021
This is mostly a duplicate of #376 and related to #359 .
Fix `README` for v5.
aryaemami59 commentedon Mar 16, 2024
This one has been resolved by #636.