diff --git a/.changeset/unify-execution-count-naming.md b/.changeset/unify-execution-count-naming.md new file mode 100644 index 000000000..b57ed1bf6 --- /dev/null +++ b/.changeset/unify-execution-count-naming.md @@ -0,0 +1,5 @@ +--- +'@tanstack/pacer': minor +--- + +breaking: rename `executeCount` to `executionCount` in `AsyncBatcherState` and `AsyncQueuerState` for consistency with all other utilities (`BatcherState`, `QueuerState`, `DebouncerState`, `ThrottlerState`, `RateLimiterState`, and `AsyncRetryerState` all use `executionCount`). The `getAbortSignal(executionCount?)` parameter on AsyncBatcher and AsyncQueuer is renamed accordingly. Pure rename, no behavior change — update any state selectors, `initialState` values, or callbacks reading `executeCount` to use `executionCount` (fixes #253) diff --git a/docs/framework/angular/guides/async-batching.md b/docs/framework/angular/guides/async-batching.md index ac6d70452..54d204194 100644 --- a/docs/framework/angular/guides/async-batching.md +++ b/docs/framework/angular/guides/async-batching.md @@ -150,7 +150,7 @@ const batcher = injectAsyncBatcher( batcher.abort() ``` -When executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/angular/guides/async-queuing.md b/docs/framework/angular/guides/async-queuing.md index 253fedf29..cdfc00a8c 100644 --- a/docs/framework/angular/guides/async-queuing.md +++ b/docs/framework/angular/guides/async-queuing.md @@ -166,7 +166,7 @@ const queue = injectAsyncQueuer( queue.abort() ``` -When multiple executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When multiple executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/preact/guides/async-batching.md b/docs/framework/preact/guides/async-batching.md index 6d9c1ea4b..5f4d404f1 100644 --- a/docs/framework/preact/guides/async-batching.md +++ b/docs/framework/preact/guides/async-batching.md @@ -156,7 +156,7 @@ const batcher = useAsyncBatcher( batcher.abort() ``` -When executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/preact/guides/async-queuing.md b/docs/framework/preact/guides/async-queuing.md index 0dea046ec..36f7f0ccb 100644 --- a/docs/framework/preact/guides/async-queuing.md +++ b/docs/framework/preact/guides/async-queuing.md @@ -168,7 +168,7 @@ const queue = useAsyncQueuer( queue.abort() ``` -When multiple executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When multiple executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/react/guides/async-batching.md b/docs/framework/react/guides/async-batching.md index f06e5e055..6f6cf002a 100644 --- a/docs/framework/react/guides/async-batching.md +++ b/docs/framework/react/guides/async-batching.md @@ -156,7 +156,7 @@ const batcher = useAsyncBatcher( batcher.abort() ``` -When executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/react/guides/async-queuing.md b/docs/framework/react/guides/async-queuing.md index 7215e5a55..cc1532b27 100644 --- a/docs/framework/react/guides/async-queuing.md +++ b/docs/framework/react/guides/async-queuing.md @@ -168,7 +168,7 @@ const queue = useAsyncQueuer( queue.abort() ``` -When multiple executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When multiple executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/solid/guides/async-batching.md b/docs/framework/solid/guides/async-batching.md index e2637c822..4e3295fd0 100644 --- a/docs/framework/solid/guides/async-batching.md +++ b/docs/framework/solid/guides/async-batching.md @@ -150,7 +150,7 @@ const batcher = createAsyncBatcher( batcher.abort() ``` -When executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/solid/guides/async-queuing.md b/docs/framework/solid/guides/async-queuing.md index a2942ee83..33810fe9b 100644 --- a/docs/framework/solid/guides/async-queuing.md +++ b/docs/framework/solid/guides/async-queuing.md @@ -158,7 +158,7 @@ const queue = createAsyncQueuer( queue.abort() ``` -When multiple executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When multiple executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/vanilla/guides/async-batching.md b/docs/framework/vanilla/guides/async-batching.md index 185fd7cc3..0d1a65d97 100644 --- a/docs/framework/vanilla/guides/async-batching.md +++ b/docs/framework/vanilla/guides/async-batching.md @@ -168,7 +168,7 @@ const batcher = new AsyncBatcher( batcher.abort() ``` -When executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/framework/vanilla/guides/async-queuing.md b/docs/framework/vanilla/guides/async-queuing.md index 987ffb5b8..de6a7f255 100644 --- a/docs/framework/vanilla/guides/async-queuing.md +++ b/docs/framework/vanilla/guides/async-queuing.md @@ -179,7 +179,7 @@ const queue = new AsyncQueuer( queue.abort() ``` -When multiple executions overlap, pass an `executeCount` to `getAbortSignal()` when you need a specific execution's signal. +When multiple executions overlap, pass an `executionCount` to `getAbortSignal()` when you need a specific execution's signal. ### Resetting safely diff --git a/docs/reference/classes/AsyncBatcher.md b/docs/reference/classes/AsyncBatcher.md index 19165a3af..86dd133fe 100644 --- a/docs/reference/classes/AsyncBatcher.md +++ b/docs/reference/classes/AsyncBatcher.md @@ -266,18 +266,18 @@ Processes the current batch of items immediately ### getAbortSignal() ```ts -getAbortSignal(executeCount?): AbortSignal | null; +getAbortSignal(executionCount?): AbortSignal | null; ``` Defined in: [async-batcher.ts:483](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L483) Returns the AbortSignal for a specific execution. -If no executeCount is provided, returns the signal for the most recent execution. +If no executionCount is provided, returns the signal for the most recent execution. Returns null if no execution is found or not currently executing. #### Parameters -##### executeCount? +##### executionCount? `number` diff --git a/docs/reference/classes/AsyncQueuer.md b/docs/reference/classes/AsyncQueuer.md index 56ed32dac..4476b17a9 100644 --- a/docs/reference/classes/AsyncQueuer.md +++ b/docs/reference/classes/AsyncQueuer.md @@ -321,18 +321,18 @@ The queue is cleared after processing ### getAbortSignal() ```ts -getAbortSignal(executeCount?): AbortSignal | null; +getAbortSignal(executionCount?): AbortSignal | null; ``` Defined in: [async-queuer.ts:889](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L889) Returns the AbortSignal for a specific execution. -If no executeCount is provided, returns the signal for the most recent execution. +If no executionCount is provided, returns the signal for the most recent execution. Returns null if no execution is found or not currently executing. #### Parameters -##### executeCount? +##### executionCount? `number` diff --git a/docs/reference/interfaces/AsyncBatcherState.md b/docs/reference/interfaces/AsyncBatcherState.md index bbfb7481e..151ee4adb 100644 --- a/docs/reference/interfaces/AsyncBatcherState.md +++ b/docs/reference/interfaces/AsyncBatcherState.md @@ -27,15 +27,15 @@ Number of batch executions that have resulted in errors *** -### executeCount +### executionCount ```ts -executeCount: number; +executionCount: number; ``` Defined in: [async-batcher.ts:16](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-batcher.ts#L16) -Number of batch executions that have been executed +Number of batch executions that have been started *** diff --git a/docs/reference/interfaces/AsyncQueuerState.md b/docs/reference/interfaces/AsyncQueuerState.md index 2403dcf60..e0899df34 100644 --- a/docs/reference/interfaces/AsyncQueuerState.md +++ b/docs/reference/interfaces/AsyncQueuerState.md @@ -51,10 +51,10 @@ Number of task executions that have resulted in errors *** -### executeCount +### executionCount ```ts -executeCount: number; +executionCount: number; ``` Defined in: [async-queuer.ts:25](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-queuer.ts#L25) diff --git a/packages/pacer/src/async-batcher.ts b/packages/pacer/src/async-batcher.ts index 06ed31879..31f0732e0 100644 --- a/packages/pacer/src/async-batcher.ts +++ b/packages/pacer/src/async-batcher.ts @@ -11,9 +11,9 @@ export interface AsyncBatcherState { */ errorCount: number /** - * Number of batch executions that have been executed + * Number of batch executions that have been started */ - executeCount: number + executionCount: number /** * Array of items that failed during batch processing */ @@ -67,7 +67,7 @@ export interface AsyncBatcherState { function getDefaultAsyncBatcherState(): AsyncBatcherState { return { errorCount: 0, - executeCount: 0, + executionCount: 0, failedItems: [], isEmpty: true, isExecuting: false, @@ -380,19 +380,19 @@ export class AsyncBatcher { return undefined } - const currentExecuteCount = this.store.state.executeCount + 1 + const currentExecutionCount = this.store.state.executionCount + 1 const batch = this.peekAllItems() // copy of the items to be processed (to prevent race conditions) this.clear() // Clear items before processing to prevent race conditions this.options.onItemsChange?.(this) - this.#setState({ isExecuting: true, executeCount: currentExecuteCount }) + this.#setState({ isExecuting: true, executionCount: currentExecutionCount }) try { const currentAsyncRetryer = new AsyncRetryer( this.fn, this.options.asyncRetryerOptions, ) - this.asyncRetryers.set(currentExecuteCount, currentAsyncRetryer) + this.asyncRetryers.set(currentExecutionCount, currentAsyncRetryer) const result = await currentAsyncRetryer.execute(batch) // EXECUTE this.#setState({ totalItemsProcessed: @@ -414,7 +414,7 @@ export class AsyncBatcher { } return undefined } finally { - this.asyncRetryers.delete(currentExecuteCount) // dispose retryer + this.asyncRetryers.delete(currentExecutionCount) // dispose retryer this.#setState({ isExecuting: false, settleCount: this.store.state.settleCount + 1, @@ -458,10 +458,10 @@ export class AsyncBatcher { /** * Returns the AbortSignal for a specific execution. - * If no executeCount is provided, returns the signal for the most recent execution. + * If no executionCount is provided, returns the signal for the most recent execution. * Returns null if no execution is found or not currently executing. * - * @param executeCount - Optional specific execution to get signal for + * @param executionCount - Optional specific execution to get signal for * @example * ```typescript * const batcher = new AsyncBatcher( @@ -480,8 +480,8 @@ export class AsyncBatcher { * ) * ``` */ - getAbortSignal = (executeCount?: number): AbortSignal | null => { - const count = executeCount ?? this.store.state.executeCount + getAbortSignal = (executionCount?: number): AbortSignal | null => { + const count = executionCount ?? this.store.state.executionCount const retryer = this.asyncRetryers.get(count) return retryer?.getAbortSignal() ?? null } diff --git a/packages/pacer/src/async-queuer.ts b/packages/pacer/src/async-queuer.ts index 3fd82f669..48a9cc27d 100644 --- a/packages/pacer/src/async-queuer.ts +++ b/packages/pacer/src/async-queuer.ts @@ -22,7 +22,7 @@ export interface AsyncQueuerState { /** * Number of times execute has been called */ - executeCount: number + executionCount: number /** * Number of items that have been removed from the queue due to expiration */ @@ -90,7 +90,7 @@ function getDefaultAsyncQueuerState(): AsyncQueuerState { activeItems: [], addItemCount: 0, errorCount: 0, - executeCount: 0, + executionCount: 0, expirationCount: 0, isEmpty: true, isExecuting: false, @@ -636,9 +636,9 @@ export class AsyncQueuer { const item = this.getNextItem(position) if (item !== undefined) { - const currentExecuteCount = this.store.state.executeCount + 1 + const currentExecutionCount = this.store.state.executionCount + 1 this.#setState({ - executeCount: currentExecuteCount, + executionCount: currentExecutionCount, isExecuting: true, }) try { @@ -646,7 +646,7 @@ export class AsyncQueuer { this.fn, this.options.asyncRetryerOptions, ) - this.asyncRetryers.set(currentExecuteCount, currentAsyncRetryer) + this.asyncRetryers.set(currentExecutionCount, currentAsyncRetryer) const lastResult = await currentAsyncRetryer.execute(item) // EXECUTE! this.#setState({ successCount: this.store.state.successCount + 1, @@ -662,7 +662,7 @@ export class AsyncQueuer { throw error } } finally { - this.asyncRetryers.delete(currentExecuteCount) // dispose retryer + this.asyncRetryers.delete(currentExecutionCount) // dispose retryer // remove only one occurrence so duplicate item values keep accurate // concurrency accounting const remainingActiveItems = [...this.store.state.activeItems] @@ -868,10 +868,10 @@ export class AsyncQueuer { /** * Returns the AbortSignal for a specific execution. - * If no executeCount is provided, returns the signal for the most recent execution. + * If no executionCount is provided, returns the signal for the most recent execution. * Returns null if no execution is found or not currently executing. * - * @param executeCount - Optional specific execution to get signal for + * @param executionCount - Optional specific execution to get signal for * @example * ```typescript * const queuer = new AsyncQueuer( @@ -886,8 +886,8 @@ export class AsyncQueuer { * ) * ``` */ - getAbortSignal = (executeCount?: number): AbortSignal | null => { - const count = executeCount ?? this.store.state.executeCount + getAbortSignal = (executionCount?: number): AbortSignal | null => { + const count = executionCount ?? this.store.state.executionCount const retryer = this.asyncRetryers.get(count) return retryer?.getAbortSignal() ?? null }