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

github.com/jsxc/jsxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/MenuItemStaticFactory.ts')
-rw-r--r--src/MenuItemStaticFactory.ts19
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,
+ };
+ }
+}