resolve command can return a Partial of TCommand instead of allowing any

This commit is contained in:
Mathias Beaulieu-Duncan 2025-09-23 15:19:56 -04:00
parent 44f296cdf8
commit d0be1dd789

View File

@ -93,7 +93,7 @@ export abstract class BaseHttpDataSourceOptionsBuilder<TQuery extends IQueryCrit
return this._messageErrorHandler(err); return this._messageErrorHandler(err);
} }
public addCommandByCallback<TCommand, TCommandResult>(name: string, commandHandler: (command: TCommand) => Observable<TCommandResult>, resolveCommandModel?: (event: IResolveCommandModelEvent<TModel>) => Observable<TCommand & any>) { public addCommandByCallback<TCommand, TCommandResult>(name: string, commandHandler: (command: TCommand) => Observable<TCommandResult>, resolveCommandModel?: (event: IResolveCommandModelEvent<TModel>) => Observable<Partial<TCommand>>) {
const handleWrapper = (command: TCommand) => { const handleWrapper = (command: TCommand) => {
return commandHandler(command).pipe(catchError(this._handleErrorPipe.bind(this))); return commandHandler(command).pipe(catchError(this._handleErrorPipe.bind(this)));
}; };
@ -108,7 +108,7 @@ export abstract class BaseHttpDataSourceOptionsBuilder<TQuery extends IQueryCrit
return this; return this;
} }
public addCommandByUrl<TCommand, TCommandResult>(name: string, url: string, resolveCommandModel?: (event: IResolveCommandModelEvent<TModel>) => Observable<TCommand & any>, beforeCommand?: (command: TCommand) => Observable<TCommand>) { public addCommandByUrl<TCommand, TCommandResult>(name: string, url: string, resolveCommandModel?: (event: IResolveCommandModelEvent<TModel>) => Observable<Partial<TCommand>>, beforeCommand?: (command: TCommand) => Observable<TCommand>) {
const handleWrapper = (command: TCommand) => { const handleWrapper = (command: TCommand) => {
const finalBeforeCommand = beforeCommand || (_ => of(command)); const finalBeforeCommand = beforeCommand || (_ => of(command));
return finalBeforeCommand(command) return finalBeforeCommand(command)