amcdnl / ngrx-actions

⚡️ Actions and Reducer Utilities for NGRX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActionType should be generic

sandangel opened this issue · comments

current implement:
symbols.ts

export type ActionType = { new (...args: any[]): Action };

We can add generic type for ActionType like this:

export type ActionType<T extends Action = Action> = { new (...args: any[]): T };

Then we can reuse it, i.e in of-action.ts

import { ActionType } from './symbols';

export function ofAction<T extends Action>(allowedType: ActionType<T>): OperatorFunction<Action, T>;

or in action.ts

export function Action(...actionsKlasses: ActionType[]) { ... }

You always have good ideas 🥇
Thank you