Skip to content

feat(appkit-ui): useAnalyticsQuery({ poll }) binding + public types (poll 3/4) - #586

Draft
atilafassina wants to merge 1 commit into
poll-2-usepollfrom
poll-3-binding
Draft

atilafassina wants to merge 1 commit into
poll-2-usepollfrom
poll-3-binding

Conversation

@atilafassina

Copy link
Copy Markdown
Contributor

Stacked PR 3 of 4 — analytics query polling. This is the one PR that changes observable behavior.
Base: poll-2-usepoll (PR 2). Merge after PR 2.

What

Compose PR 1's uncached refetch with PR 2's usePoll scheduler behind a new poll option on useAnalyticsQuery.

  • poll?: true | { intervalMs, immediate, backoff, maxConsecutiveErrors, onPoll }.
  • Returns the existing fields plus a typed poll control/telemetry object (present only in poll mode).
  • Each tick drives store.refetch(cacheKey) (uncached); retain(autoStart:false) makes the scheduler the sole trigger; a param change is consumed on the next tick (never self-fired); a cacheKeyRef guard ensures a late completion from an old key cannot mutate the current snapshot (StrictMode abort-restart race).
  • data latest-only; loading toggles per tick; warehouseStatus still surfaces on cold polls. Non-poll behavior unchanged; usePoll stays internal.

Stack

  1. internal refetch + uncached mode
  2. internal usePoll scheduler
  3. ← this PR useAnalyticsQuery({ poll }) binding + public types
  4. docs

Tests

+15 polling tests (late-event race guard, next-tick param change, uncached/skipCache, autoStart-forced-false, onPoll, latest-only data, both type forms); full suite green (4788 passed).

This pull request and its description were written by Isaac.

…se 3)

Compose the phase-1 uncached refetch with the phase-2 usePoll scheduler
behind a new poll option — the one behavior-adding change in this chain.

useAnalyticsQuery(key, params, { poll }) accepts `true | { intervalMs,
immediate, backoff, maxConsecutiveErrors, onPoll }` and returns the existing
fields plus a typed `poll` control/telemetry object (paused, pause, resume,
restart, refetch, attempts, errors, skipped, consecutiveErrors,
lastLatencyMs, latency:{p50,p95}), present only in poll mode.

When poll is set: each tick drives store.refetch(cacheKey) for genuine
uncached re-execution (skipCache), retain(autoStart:false) makes the
scheduler the sole trigger, a param change is consumed on the next tick
(never self-fired), and a cacheKeyRef guard ensures a late completion from
an old key cannot mutate the current snapshot. data stays latest-only;
loading toggles per tick; warehouseStatus still surfaces on cold polls.
Non-poll behavior is unchanged. usePoll stays internal (not in any barrel);
public poll types live in types.ts.

xavier loop: iteration 4 (phase 3/4)

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Atila Fassina <atila@fassina.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant