trackJob()
Starts tracking an async backend job at runtime — for jobs that didn't exist yet when your stores were registered. The realtime and polling transports share one interpreter, so onProgress, onComplete, and onFailure behave identically no matter which one is wired up.
- flux created via createFlux() — see api/create-flux
- A state manager store (Zustand natively, or a Redux/Jotai adapter) to receive progress
Basic usage
flux.trackJob() the moment you first learn a job's ID — typically right after an offline-queued upload finally replays and your backend hands back a job_id in its response.If a channel always carries job rows and you know that at registration time, use the jobTracker field on register() instead — see api/register. Reach for trackJob() specifically when the job ID doesn't exist until runtime.
Config reference
trackBy is required. It's the same JobTrackerConfig shape used by the static register() path.Status and progress field detection
scope — set explicitly, never inherited
jobTracker inherits scope from its parent store. A dynamically tracked job has no parent registration to inherit from at all — if this job belongs to a logged-in user's private flow, set scope: 'user' yourself so it's cleared by clearUserSession().Flux deliberately doesn't try to guess scope by pattern-matching trackBy against existing registrations — values like job_id are generic and shared across unrelated trackers, which makes that kind of inference unreliable. See core-concepts/multi-tenant-scoping.
Dual transport, one interpreter
Polling fallback
pollFn for jobs with no realtime channel backing them. Polling is visibility- and offline-aware, and never stacks requests on a slow connection.Cleanup
trackJob() returns an unregister function, the same shape as register(). A normal terminal transition already cleans itself up — you only need to call this for an early unmount.For jobs known at registration time, see the jobTracker field in api/register. For the full offline-upload-to-tracked-job flow, see offline/upload-pattern and core-concepts/job-tracker.