mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
change: Refactor AllVoidCompositeHandler into SequenceHandler.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
7cae14acf7
commit
ba47ce7951
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Simple interface for classes that can potentially handle a specific kind of data asynchronously.
|
||||
*/
|
||||
export abstract class AsyncHandler<TInput = void, TOutput = void> {
|
||||
export abstract class AsyncHandler<TIn = void, TOut = void> {
|
||||
/**
|
||||
* Checks if the input data can be handled by this class.
|
||||
* Throws an error if it can't handle the data.
|
||||
@@ -10,7 +10,7 @@ export abstract class AsyncHandler<TInput = void, TOutput = void> {
|
||||
* @returns A promise resolving if this input can be handled, rejecting with an Error if not.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public async canHandle(input: TInput): Promise<void> {
|
||||
public async canHandle(input: TIn): Promise<void> {
|
||||
// Support any input by default
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export abstract class AsyncHandler<TInput = void, TOutput = void> {
|
||||
*
|
||||
* @returns A promise resolving when the handling is finished. Return value depends on the given type.
|
||||
*/
|
||||
public abstract handle(input: TInput): Promise<TOutput>;
|
||||
public abstract handle(input: TIn): Promise<TOut>;
|
||||
|
||||
/**
|
||||
* Helper function that first runs the canHandle function followed by the handle function.
|
||||
@@ -30,7 +30,7 @@ export abstract class AsyncHandler<TInput = void, TOutput = void> {
|
||||
*
|
||||
* @returns The result of the handle function of the handler.
|
||||
*/
|
||||
public async handleSafe(data: TInput): Promise<TOutput> {
|
||||
public async handleSafe(data: TIn): Promise<TOut> {
|
||||
await this.canHandle(data);
|
||||
|
||||
return this.handle(data);
|
||||
|
||||
Reference in New Issue
Block a user