Replies: 4 comments 1 reply
-
|
Not at this time. Been thinking about it, but I'd probably have to create something new like a KeyParameterFactory or some such since the parameter would need to be hashable and currently they can be anything. What would you think if they were simply hashable and the hash value was the key? Chances of a collision would be extremely low. How many cached objects are you considering? |
Beta Was this translation helpful? Give feedback.
-
|
Well, that said... ParameterFactory ScopesBy default, ParameterFactory scopes will cache the first requested value and then return the service created with that value, even if other values are passed on future requests. The behavior can be changed with the var parameterService: ParameterFactory<Int, ParameterService> {
self { ParameterService(value: $0) }.scopeOnParameters.cached
}The passed parameter must be Hashable for this modifier to appear and for the per-parameter caching functionality to occur. That code is in the develop branch as part of 2.5.0. |
Beta Was this translation helpful? Give feedback.
-
|
It's also in the recent 2.4.13 release pushed to CocoaPods. |
Beta Was this translation helpful? Give feedback.
-
|
I can confirm that it works as expected. Thanks for adding this functionality. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
Is there an option to take the parameter into account when caching the instance in order to return unique instances, based on the parameter?
(Similar to memoizee)
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions