First improvement is adding a TypeKey value type to normalize types.
Cleanse has a type of one-to-many mapping for a given dependency to how it can be used within the object graph. For a given Type, it can be represented as Provider<Type>, WeakProvider<Type>, or () -> Type. Currently we support this by adding each of these types into the object graph dictionary for key lookup during dependency resolution. However, for other resolution steps (i.e duplicate binding, cyclical dependencies), we filter these types out so that we don't over-report errors or run into false-positive. The TypeKey helps normalize the types we see in the graph so that we don't have to unnecessarily add and filter certain types during resolution.
Refactors resolution functions into their primary operating type.
Most steps are just static functions with the primary operating type passed in as a parameter. We can make this a bit more "swifty" by moving the code into an extension on these types.
TypeKey
value type to normalize types.Cleanse has a type of one-to-many mapping for a given dependency to how it can be used within the object graph. For a given
Type
, it can be represented asProvider<Type>
,WeakProvider<Type>
, or() -> Type
. Currently we support this by adding each of these types into the object graph dictionary for key lookup during dependency resolution. However, for other resolution steps (i.e duplicate binding, cyclical dependencies), we filter these types out so that we don't over-report errors or run into false-positive. TheTypeKey
helps normalize the types we see in the graph so that we don't have to unnecessarily add and filter certain types during resolution.Most steps are just static functions with the primary operating type passed in as a parameter. We can make this a bit more "swifty" by moving the code into an extension on these types.