Skip to main content

shouldCoalesce()

shouldCoalesce(prevSig: string | undefined, nextSig: string, prevAt: number, now: number, coalesceMs?: number): boolean

Defined in: packages/core/src/utils/coalesce.ts:24

Determines whether a change should be absorbed into the current history entry instead of pushing a new one. This is the exact rule QueryManager applies when recording history, exposed so non-React implementations can manage their own history stacks without reimplementing (and drifting from) the semantics.

A change coalesces only when all three hold:

  • the change is not structural (rules/groups added, removed, moved, or reordered)
  • its signature matches the previously recorded signature
  • it occurred within coalesceMs of the previous recording

Note that unchangedSignature is not handled here. A change with no observable difference is never recorded at all, which is a separate decision made before this check.

Parameters

ParameterTypeDefault valueDescription
prevSigstring | undefinedundefinedSignature of the previously recorded change, or undefined if there is none.
nextSigstringundefinedSignature of the change being recorded, from signatureOf.
prevAtnumberundefinedTimestamp of the previous recording.
nownumberundefinedTimestamp of the change being recorded.
coalesceMsnumberdefaultCoalesceMsCoalescing window in milliseconds.

Returns

boolean


caution

API documentation is generated from the latest commit on the main branch. It may be somewhat inconsistent with official releases of React Query Builder.