diff options
Diffstat (limited to 'src/MenuItemStaticFactory.ts')
-rw-r--r-- | src/MenuItemStaticFactory.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/MenuItemStaticFactory.ts b/src/MenuItemStaticFactory.ts new file mode 100644 index 00000000..cbd44959 --- /dev/null +++ b/src/MenuItemStaticFactory.ts @@ -0,0 +1,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, + }; + } +} |