Function overload
One implementation for many signatures.
Another approach would be to simply receive the categoriesIds
in the DTO.
After that, we could transform them to the objects mentioned in the previous solution. For better encapsulation, in the file common -> util -> id.util, create the function wrapId()
. We'll use a function overload to have just a single implementation, preventing the need to write two separate functions depending on the parameter (one or many ids). The tooltip adapts depending on the input provided.
Notice the following:
The last signature is the implementation one, not available when calling
The return type needs to be explicit when overloading
The function is used in its regular form (not arrow) to allow for the overload
What remains to be done is to, in the ProductsService
, wrap the ids and use them.
Commit - Function overload for wrapping ids
Last updated