RefreshSchedule
The timer behind a list that refreshes itself.
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
new RefreshSchedule(init: RefreshSchedule.Init)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
init | RefreshSchedule.Init | Yes | The interval and the reload to run. |
Properties
| Property | Type | Required | Description |
|---|---|---|---|
every | readonly number | Yes | Milliseconds between reloads. |
refreshedAt | Date | Yes | When the last reload finished, or the initial content was fetched. |
paused | boolean | Yes | Whether the schedule is waiting to be resumed. |
Methods
| Method | Description |
|---|---|
start(): void | Starts counting toward the next reload from the last refresh. |
pause(): void | Holds the next reload until resume; a reload already running finishes. |
resume(): void | Continues the schedule, reloading at once when a full interval passed while paused. |
stop(): void | Ends the schedule for good. |
Examples
let schedule = new RefreshSchedule({ every: 30_000, reload: () => frame.reload() }); schedule.start();Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/app too.
Interface
RefreshSchedule.Init
Construction options.
| Member | Type | Required | Description |
|---|---|---|---|
every | number | Yes | Milliseconds from the end of one reload to the start of the next; 0 or less never reloads. |
reload | () => Promise<unknown> | Yes | Reloads what the schedule keeps current; a rejection leaves the schedule running. |
refreshedAt | Date | No | When the content on screen was last fetched. Defaults to construction time. |
Interface
RefreshSchedule.Events
Events dispatched by RefreshSchedule.
| Member | Type | Required | Description |
|---|---|---|---|
refresh | Event | Yes | A reload finished; read refreshedAt for when. |