Introduction of my app structure: I have a lists-service
that handles lists from API, standardized to columns and rows. It includes mapping, sorting, pagination and other functionality.
For each API, I have created child service (that extends ListsService
), for example for list of users - UsersListService
, actions - ActionsListService
and so on.
These child services have their own data and some extra functions, specific to each.
These services are provided in the root, because in addition to being injected into each page component, they are also injected into sidebar components.
More specifically: I have LicenseListService
:
@Injectable({
providedIn: 'root'
})
export class LicenseListService extends ListsService {....}
It's injected into UserLicenseComponent
(route component)
constructor(...
public licenseList: LicenseListService,
... ) {...}
But also in LicenseSidebarComponent
, which is used in different place.
What I need
I need 2 instances of this LicenseListService
, they would use the same input data (from same API), but in one I will have active licenses and in the other expired licences (so that both tables can be displayed at the same time.
One way to do it is to create child services from LicenseListService
, but I would rather have 2 instances of the same service, but with status parameter (status = 'active' or status = 'expired').
What is the best way to do it?
I've seen some partial solutions (to my issue) on stackoverflow, but need to combine it into full solution.