Ecodev / natural

Angular Material components and various utilities

Home Page:https://ecodev.github.io/natural

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use service as generic

PowerKiKi opened this issue · comments

NaturalAbstractList and NaturalAbstractDetail generic types should be parameterized with a single implementation of NaturalAbstractModelService, instead of a multitude of Tall, Vall, Tone, Vone. The Tall/Vall things can be extracted from the service itself when needed.

This would allow to strongly type usage of the service itself in those classes and inheriting classes. Specifically prohibiting the usage of a service method if it is not supported, because not all services support fetching single items (or multiple items).

Usage before:

export class ActionComponent extends AbstractDetail<Action['action'],
    ActionVariables,
    CreateAction['createAction'],
    CreateActionVariables,
    UpdateAction['updateAction'],
    UpdateActionVariables,
    DeleteActions['deleteActions']> implements OnInit {

Usage after:

export class ActionComponent extends AbstractDetail<ActionService> implements OnInit {