Skip to content

Commit 841bb66

Browse files
committed
fix: rename cmd functions
This is a refactoring only but marked as fix to release a new version
1 parent 6717081 commit 841bb66

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/cmd.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ const cmd = {
5555
* @param args The parameters of the task.
5656
*/
5757
ofSuccess<TMessage extends Message, TArgs extends unknown [], TReturn>(task: (...args: TArgs) => TReturn, ofSuccess: (result: Awaited<TReturn>) => TMessage, ...args: TArgs): Cmd<TMessage> {
58-
const defaultFallbackHandler = (): void => {
59-
// blank
60-
};
61-
6258
const bind = (dispatch: Dispatch<TMessage>, fallback: FallbackHandler = defaultFallbackHandler): void => {
6359
try {
6460
const taskResult = task(...args);
@@ -179,7 +175,8 @@ const cmd = {
179175
*/
180176
either<TMessage extends Message, TArgs extends unknown [], TReturn>(task: (...args: TArgs) => Promise<TReturn>, ofSuccess: (result: TReturn) => TMessage, ofError: (error: Error) => TMessage, ...args: TArgs): Cmd<TMessage> {
181177
const bind = (dispatch: Dispatch<TMessage>): void => {
182-
task(...args).then(result => dispatch(ofSuccess(result)))
178+
task(...args)
179+
.then(result => dispatch(ofSuccess(result)))
183180
.catch((ex: Error) => dispatch(ofError(ex)));
184181
};
185182

@@ -193,12 +190,9 @@ const cmd = {
193190
* @param args The parameters of the task.
194191
*/
195192
perform<TMessage extends Message, TArgs extends unknown [], TReturn>(task: (...args: TArgs) => Promise<TReturn>, ofSuccess: (result: TReturn) => TMessage, ...args: TArgs): Cmd<TMessage> {
196-
const defaultFallbackHandler = (): void => {
197-
// blank
198-
};
199-
200193
const bind = (dispatch: Dispatch<TMessage>, fallback: FallbackHandler = defaultFallbackHandler): void => {
201-
task(...args).then(result => dispatch(ofSuccess(result)))
194+
task(...args)
195+
.then(result => dispatch(ofSuccess(result)))
202196
.catch(fallback);
203197
};
204198

@@ -226,6 +220,10 @@ const cmd = {
226220
},
227221
};
228222

223+
function defaultFallbackHandler (): void {
224+
// blank
225+
}
226+
229227
export {
230228
cmd,
231229
};

0 commit comments

Comments
 (0)