How to pass multiple generic services into library
Say I'm building a library, and that library has an assortment of different filter controls, like a text input, dropdown, checkbox, etc...
I then want to be able to provide a service to those filter controls, generically, preferably where I could have multiple services, each one shares a generic interface, but with a type.
FilterService<T>
UserService implements FilterService<User>
CarService implements FilterService<Car>
HouseService implements FilterService<House>
So then you have a chain of components in the library, but maybe pass T up through them.
FilterListComponent<T>
template contains multiple of these:
TextInputComponent<T>
Then, TextInputComponent<User> gets the type User, but it calls for FilterService<User>, it should get the UserService that implements the interface FilterService<User>. And later on, if you do TextInputComponent<Car> it would get the FilterService<Car>.
Can anyone point me in the right direction to accomplish something like this? It feels like it should be possible.
Posted Mar 22, 2022, 6:59 PM UTC
https://youtu.be/rcDsRyVhcxY
Maybe something like the composition example here?
Thanks! That looks really interesting... I might have to look into this further. Sometimes you just have to hear something described in the right way for it to make sense. I need to find a good resource to learn angular design patterns. I have yet to find anything good that goes beyond Maximillian's udemy course.