SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

RefreshSchedule

The timer behind a list that refreshes itself.

tsx
import { RefreshSchedule } from "@sdxc/ui/app";

Usage

Reloads on an interval measured from the last finished reload, so a slow reload never stacks a second one behind it, and a resume after a long pause catches up with one reload.

Signature

typescript
new RefreshSchedule(init: RefreshSchedule.Init)

Parameters

ParameterTypeRequiredDescription
initRefreshSchedule.InitYesThe interval and the reload to run.

Properties

PropertyTypeRequiredDescription
everyreadonly numberYesMilliseconds between reloads.
refreshedAtDateYesWhen the last reload finished, or the initial content was fetched.
pausedbooleanYesWhether the schedule is waiting to be resumed.

Methods

MethodDescription
start(): voidStarts counting toward the next reload from the last refresh.
pause(): voidHolds the next reload until resume; a reload already running finishes.
resume(): voidContinues the schedule, reloading at once when a full interval passed while paused.
stop(): voidEnds the schedule for good.

Examples

tsx
let schedule = new RefreshSchedule({ every: 30_000, reload: () => frame.reload() }); schedule.start();

The events, constants and types its module publishes, each imported from @sdxc/ui/app too.

Interface

RefreshSchedule.Init

Construction options.

MemberTypeRequiredDescription
everynumberYesMilliseconds from the end of one reload to the start of the next; 0 or less never reloads.
reload() => Promise<unknown>YesReloads what the schedule keeps current; a rejection leaves the schedule running.
refreshedAtDateNoWhen the content on screen was last fetched. Defaults to construction time.
Interface

RefreshSchedule.Events

Events dispatched by RefreshSchedule.

MemberTypeRequiredDescription
refreshEventYesA reload finished; read refreshedAt for when.
@sdxc/ui

Can’t find it? Contact us