本页还没有译文
本页 44 段还没译成Español,下面显示的是英文原文。UseQueuer
还没翻译译自英文(tanstack.com)本页 44 段都还没译
Defined in: packages/ember-pacer/src/queuer/useQueuer.ts:91
Creates and retains the Queuer for its Ember owner.
Retains items until they are processed. Use addItem to enqueue work and start, stop, execute, clear, or flush to control processing. Selected state exposes pending items, capacity, and completed work.
State and subscriptions
Pass a selector to track only the state consumed by the owner. The default selection is {}, so utility state changes do not update the owner unless it opts in. Selection uses shallow comparison. The raw store remains available for additional subscriptions. The selector is the second positional argument. Read utility.state from the template. The contextual utility.Subscribe helper selects state for a child template.
Available state fields:
addItemCount: Number of times addItem has been called (for reduction calculations)executionCount: Number of items that have been processed by the queuerexpirationCount: Number of items that have been removed from the queue due to expirationisEmpty: Whether the queuer has no items to process (items array is empty)isFull: Whether the queuer has reached its maximum capacityisIdle: Whether the queuer is not currently processing any itemsisRunning: Whether the queuer is active and will process items automaticallyitems: Array of items currently waiting to be processeditemTimestamps: Timestamps when items were added to the queue for expiration trackingpendingTick: Whether the queuer has a pending timeout for processing the next itemrejectionCount: Number of items that have been rejected from being added to the queuesize: Number of items currently in the queuestatus: Current processing status - 'idle' when not processing, 'running' when active, 'stopped' when paused
Options and ownership
Tracked named arguments update options after rendering. createPacerScope supplies shared defaults through contextual helpers. Local named options override those defaults. Removing the helper invocation calls stop(). onUnmount replaces default cleanup and receives the same adapter instance. A custom callback must perform all required cleanup. Use flush() where supported to finish pending work.
Example
import { on } from '@ember/modifier'
import { fn } from '@ember/helper'
import { useQueuer } from '@tanstack/ember-pacer'
import type { QueuerState } from '@tanstack/ember-pacer'
const select = (state: QueuerState<string>) => ({ size: state.size })
<template>
{{#let (useQueuer @process select wait=100) as |utility|}}
<button {{on "click" (fn utility.addItem "item")}}>Schedule</button>
<span>{{utility.state.size}}</span>
{{/let}}
</template>Extends
default<{Args: {Named:EmberQueuerOptions<TValue,TSelected>;Positional: [(item) =>void] | [(item) =>void, (state) =>TSelected]; };Return:EmberQueuer<TValue,TSelected>; }>
Type Parameters
TValue
TValue
TSelected
TSelected = {
}
Constructors
Constructor
new UseQueuer<TValue, TSelected>(owner?): UseQueuer;Defined in: node_modules/.pnpm/ember-source@7.3.0_@glimmer+component@2.1.1_supports-color@7.2.0__supports-color@7.2.0/node_modules/ember-source/types/stable/@ember/object/index.d.ts:28
Parameters
owner?
Owner
Returns
UseQueuer
Inherited from
Helper<{
Args: {
Positional:
| [fn: (item: TValue) => void]
| [
fn: (item: TValue) => void,
selector: (state: QueuerState<TValue>) => TSelected,
]
Named: EmberQueuerOptions<TValue, TSelected>
}
Return: EmberQueuer<TValue, TSelected>
}>.constructorMethods
compute()
compute(positional, options): EmberQueuer<TValue, TSelected>;Defined in: packages/ember-pacer/src/queuer/useQueuer.ts:111
Override this function when writing a class-based helper.
Parameters
positional
[(item) => void, (state) => TSelected]
The positional arguments to the helper
options
EmberQueuerOptions<TValue, TSelected>
Returns
EmberQueuer<TValue, TSelected>
Method
compute
Since
1.13.0
Overrides
Helper.compute