make tryExecuteAndNotify wrapper more straight forward

This commit is contained in:
Jacob Overgaard
2023-01-03 15:52:23 +01:00
parent 9c5b5368ce
commit 6f3abc00a7
2 changed files with 4 additions and 4 deletions

View File

@@ -1 +1,2 @@
export * from './resource.controller';
export * from './tryExecuteAndNotify.method';

View File

@@ -1,13 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { UmbControllerHostInterface } from '../controller/controller-host.mixin';
import type { ProblemDetails } from '../backend-api/models/ProblemDetails';
import { UmbResourceController } from './resource.controller';
import { UmbNotificationOptions } from 'src/core/notification';
export async function tryExecuteAndNotify<T>(
export function tryExecuteAndNotify<T>(
host: UmbControllerHostInterface,
resource: Promise<T>,
options?: UmbNotificationOptions<any>
): Promise<{ data?: T; error?: ProblemDetails }> {
return await new UmbResourceController(host, resource).tryExecuteAndNotify<T>(options);
) {
return new UmbResourceController(host, resource).tryExecuteAndNotify<T>(options);
}