add action base class

This commit is contained in:
Mads Rasmussen
2024-03-02 23:22:26 +01:00
parent 2655e8a789
commit 5538e49f97
3 changed files with 16 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
import type { UmbAction } from './action.interface.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export abstract class UmbActionBase<ArgsType> implements UmbAction<ArgsType> {
public args: ArgsType;
protected _host: UmbControllerHost;
constructor(host: UmbControllerHost, args: ArgsType) {
this._host = host;
this.args = args;
}
abstract execute(): Promise<void>;
abstract destroy(): Promise<void>;
}

View File

@@ -1,8 +1,6 @@
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
export interface UmbAction<ArgsType> extends UmbApi {
args: ArgsType;
execute(): Promise<void>;
_host: UmbControllerHost;
}

View File

@@ -1,2 +1,3 @@
export * from './action.interface.js';
export * from './action-event.context.js';
export * from './action-base.js';