@@ -37,7 +37,7 @@ export interface ActionOptions<T, R, E> {
37
37
onSuccess ?: ( result : R ) => void ;
38
38
onFailure ?: ( failure : FailedAction < E > ) => void ;
39
39
/**
40
- * @default waitForPrevious
40
+ * @default ignoreNewUntilPreviousIsFinished
41
41
*/
42
42
combinator ?: ActionsCombinator < E > ;
43
43
/**
@@ -51,20 +51,21 @@ export interface ActionOptions<T, R, E> {
51
51
}
52
52
53
53
/**
54
- * Wait for completion of previous action
54
+ * Forget previous action
55
55
*/
56
- export const waitForPrevious : ActionsCombinator < any > = ( { status } ) =>
57
- status <= Status . IDLE ;
56
+ export const forgetPrevious : ActionsCombinator < any > = ( ) => true ;
58
57
59
58
/**
60
59
* Abort previous action
61
60
*/
62
61
export const abortPrevious : ActionsCombinator < any > = ( ) => "abort" ;
63
62
64
63
/**
65
- * Ignore previous action
64
+ * Ignore new actions until the previous action is completed
66
65
*/
67
- export const ignorePrevious : ActionsCombinator < any > = ( ) => true ;
66
+ export const ignoreNewUntilPreviousIsFinished : ActionsCombinator < any > = ( {
67
+ status,
68
+ } ) => status <= Status . IDLE ;
68
69
69
70
export type ActionRun < T > = T extends undefined | unknown
70
71
? ( value ?: T ) => Promise < void >
@@ -86,7 +87,9 @@ export function useAction<T, R, E = unknown>(
86
87
) : Action < T , R , E > {
87
88
const delayedMs = $derived ( options . delayedMs ?? 500 ) ;
88
89
const timeoutMs = $derived ( options . timeoutMs ?? 8000 ) ;
89
- const combinator = $derived ( options . combinator ?? waitForPrevious ) ;
90
+ const combinator = $derived (
91
+ options . combinator ?? ignoreNewUntilPreviousIsFinished
92
+ ) ;
90
93
91
94
let state = $state < ActionState < E > > ( {
92
95
status : Status . IDLE ,
0 commit comments