From 3e2f6967fb86ed9ab782b7a1c02fcccde8ac885c Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Tue, 18 Oct 2022 15:00:07 -0500 Subject: [PATCH] Improve documentation and simplify the property types in Callbacks/run.ts --- app/javascript/common/Callbacks/run.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/javascript/common/Callbacks/run.ts b/app/javascript/common/Callbacks/run.ts index 26652f9df..3346f8bf6 100644 --- a/app/javascript/common/Callbacks/run.ts +++ b/app/javascript/common/Callbacks/run.ts @@ -1,13 +1,15 @@ // License: LGPL-3.0-or-later -import Callback from "./Callback"; +import type { CallbackClass } from "./types"; /** * A very simple function for conditionally running callbacks. Move into own file because we can mock it for CallbackController * @param input The input properties to every callback - * @param callbacks callbacks to be run + * @param callbacks callbacks as classes to be run + * @template TCallbackProps the properties to be passed into the constructor of each Callback + * @returns {Promise} a promise resolving on completion of all of the callbacks. Doesn't currently ever reject. */ -export default async function run(input: TCallbackInput, callbacks: ReadonlyArray<{ new(input: TCallbackInput): Callback }>): Promise { +export default async function run(input: TCallbackProps, callbacks: readonly CallbackClass[]): Promise { try { for (const callback of callbacks) { const obj = new callback(input);