Skip to content

Commit

Permalink
Improve documentation and simplify the property types in Callbacks/ru…
Browse files Browse the repository at this point in the history
…n.ts
  • Loading branch information
wwahammy committed Oct 19, 2022
1 parent bc460c6 commit c252921
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/javascript/common/Callbacks/run.ts
Original file line number Diff line number Diff line change
@@ -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<void>} a promise resolving on completion of all of the callbacks. Doesn't currently ever reject.
*/
export default async function run<TCallbackInput>(input: TCallbackInput, callbacks: ReadonlyArray<{ new(input: TCallbackInput): Callback<TCallbackInput> }>): Promise<void> {
export default async function run<TCallbackProps>(input: TCallbackProps, callbacks: readonly CallbackClass<TCallbackProps>[]): Promise<void> {
try {
for (const callback of callbacks) {
const obj = new callback(input);
Expand Down

0 comments on commit c252921

Please sign in to comment.