Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MenuItemStaticFactory.ts « src - github.com/jsxc/jsxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cbd449595e327b33d12fcf9a2999a4aa3b3899fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import IMenuItemFactory, { MenuItem } from './MenuItemFactory.interface';

export default class MenuItemStaticFactory<Params extends any[] = any[]> implements IMenuItemFactory<Params> {
   constructor(
      private id: string,
      private label: string,
      private handler: (...args: Params) => void,
      private icon?: string
   ) {}

   public generate(...args: Params): MenuItem {
      return {
         id: this.id,
         label: this.label,
         handler: () => this.handler(...args),
         icon: this.icon,
      };
   }
}