-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Change the default value of the cachePromiseRejection
option to true
#36
Conversation
I can see arguments for having the default both // @LinusU |
I think it should be set to |
This is a hard one, there are definitely arguments for both sides, but I'm personally leaning against |
@LinusU Can you elaborate on why? |
I was unaware of this behavior until Sindre tweeted about it. I really don't see what memoization has to do with promises altogether. Therefore, I also don't see why the option even exists, let alone why it has an unintuitive default. At most, I would expect if from a hypothetical If you keep this behavior, please make it more clear in the readme. |
That's not a bad point, actually, since https://github.com/sindresorhus/p-memoize exists and is promise-specific. However as I said in my first post:
|
Sorry for the short response 😄 On the one hand, you could argue that since it doesn't That being said, I think that it becomes quite "magic" when it removes It just seems like which behavior you want is very usage-dependent, and it's impossible to pick a perfect default. Therefore I think that the less "magic" way should be the default, as not to accidentally opt people into something they might not be aware of. Just my 2¢
I also agree with this, I think that this package shouldn't deal with promises at all, since we have |
Thanks everyone for sharing useful feedback. 🙌 Since we're pretty split on what the default should be, I buy the argument about doing the least magic/surprising thing by default. |
Yeah, maybe, but I'll keep it for now as |
cachePromiseRejection
option to true
As a feature, this already feels weird because caching depends on this specific mechanism and not others like:
false
?{cache: false}
?Having it avoid cache just because a promise is rejected feels arbitrary... but in a way I see that it's a flexible mechanism that allows any function (sync or async) to decide whether to avoid the cache.
That said, I don't think it should be a default, because: