@amazon-devices/kepler-epg-sync-scheduler
The @amazon-devices/kepler-epg-sync-scheduler package provides APIs for scheduling Electronic Program Guide (EPG) synchronization tasks in React Native for Vega apps. It offers flexible scheduling options with both interval-based and time-window-based execution.
Overview
The Kepler EPG Sync Scheduler allows you to:
- Schedule periodic EPG sync tasks at regular intervals
- Schedule EPG sync tasks within specific time windows (For example, between 2AM-4AM UTC)
- Cancel existing scheduled tasks
Public APIs
Main Scheduler
EpgSyncTaskScheduler
The main scheduler instance that implements the IEpgSyncTaskScheduler interface.
import {EpgSyncTaskScheduler} from '@amazon-devices/kepler-epg-sync-scheduler';
Interfaces
IEpgSyncTaskScheduler
The main interface exposing EPG sync task scheduling functions.
Methods:
scheduleTask(componentId: string, interval: number): Promise<void>
Schedules an EPG sync task to run at regular intervals.
- Parameters:
componentId: The component ID for the JS background task to scheduleinterval: Time interval in minutes (must be between 5 and 1440 minutes inclusive)
- Behavior:
- Runs the task immediately upon scheduling
- Then schedules recurring execution at the specified interval
- Only one EPG sync task can be scheduled at a time
- Persists across device reboots
- Throws:
InternalErrorif scheduling fails - Returns: Promise that resolves when scheduling is complete
scheduleTaskWithExecutionWindow(componentId: string, timeProperties: ITimeProperties): Promise<void>
Schedules an EPG sync task to run daily within a specific time window.
- Parameters:
componentId: The component ID for the JS background task to scheduletimeProperties: Time constraints for task execution (created usingUtcTimePropertiesBuilder)
- Behavior:
- Runs the task immediately upon scheduling
- Then schedules daily execution within the specified UTC time window
- You can only schedule one EPG sync task at a time
- Persists across device reboots
- Throws:
InternalErrorif scheduling fails - Returns: Promise that resolves when scheduling is complete
cancelScheduledTasks(): Promise<void>
Cancels all existing scheduled EPG sync tasks.
- Behavior:
- Cancels tasks scheduled by either
scheduleTask()orscheduleTaskWithExecutionWindow() - Succeeds even if no tasks are currently scheduled
- Cancels tasks scheduled by either
- Throws:
InternalErrorif cancellation fails - Returns: Promise that resolves when cancellation is complete
Time Properties
ITimeProperties
An interface that describes time constraints for task execution. Use UtcTimePropertiesBuilder to create instances.
UtcTimePropertiesBuilder
Builder class for creating UTC-based time properties with execution windows.
Methods:
startHour(hour: number): UtcTimePropertiesBuilder
Sets the start hour (0-23) for the execution window.
- Required field
- Throws:
InvalidArgumentErrorif hour is not between 0-23 - Throws:
IllegalStateErrorif builder has already been used
startMinute(minute: number): UtcTimePropertiesBuilder
Sets the start minute (0-59) for the execution window.
- Required field
- Throws:
InvalidArgumentErrorif minute is not between 0-59 - Throws:
IllegalStateErrorif builder has already been used
startSecond(second: number): UtcTimePropertiesBuilder
Sets the start second (0-59) for the execution window.
- Required field
- Throws:
InvalidArgumentErrorif second is not between 0-59 - Throws:
IllegalStateErrorif builder has already been used
executionWindowInMinutes(window: number): UtcTimePropertiesBuilder
Sets the length of the execution window in minutes.
- Optional field (defaults to 60 minutes)
- Throws:
InvalidArgumentErrorif window is less than 60 minutes - Throws:
IllegalStateErrorif builder has already been used
build(): ITimeProperties
Builds the final TimeProperties object.
- Throws:
InvalidArgumentErrorif the required fields are missing - Throws:
IllegalStateErrorif the builder has already been used - Note: You can only use builder instances once
Error Types
InternalError
A custom error that indicates something went wrong when scheduling the EPG sync task.
InvalidArgumentError
An exception that is thrown when there is a failure to create a new object due to invalid arguments.
IllegalStateError
An exception that is thrown when you call builder functions after you have already used the builder to build an object.
Important Notes
- You can schedule only one EPG sync task at any point in time
- The most recent scheduling call will override any previous scheduling
- Scheduled tasks persist across device reboots
- All time-based scheduling uses UTC time
- You can only use a Builder instances used once and you can't reuse it after calling
build() - Interval scheduling accepts values between 5 and 1440 minutes (1 day)
- Execution window scheduling requires a minimum window of 60 minutes (1 hour)
Error Handling
All scheduling operations are asynchronous and might throw InternalError exceptions. Always wrap scheduling calls in try-catch blocks or handle Promise rejections appropriately.
The builder pattern used for time properties might throw InvalidArgumentError for invalid parameters or IllegalStateError if attempting to reuse a builder instance.
Developer Guide
For detailed integration steps, see Overview of EPG Integration.
Modules
- index
- turbo-modules/Builder
- turbo-modules/Builder
- turbo-modules/EpgSyncTaskScheduler
- turbo-modules/EpgSyncTaskScheduler
- turbo-modules/Error
- turbo-modules/Error
- turbo-modules/NativeEpgSyncTaskScheduler
- turbo-modules/NativeEpgSyncTaskScheduler
- turbo-modules/TimeProperties
- turbo-modules/TimeProperties
Last updated: Nov 10, 2025

