Skip to content

Commit

Permalink
Periodic sync options
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiancook committed Sep 29, 2023
1 parent 19b70f2 commit fa2195b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/periodic-sync/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import {getKeyValueStore} from "../data";
import {ok} from "../is";
import {SyncTag, SyncTagRegistrationState} from "../sync";

export interface PeriodicSyncTag extends SyncTag {
export interface PeriodicSyncOptions {
minInterval?: number;
}

export interface PeriodicSyncTag extends SyncTag, PeriodicSyncOptions {

}

Expand Down Expand Up @@ -40,7 +44,7 @@ export async function deregisterPeriodicSyncTag(tag: string) {
}

export class DurablePeriodicSyncManager {
async register(tag: string) {
async register(tag: string, options?: PeriodicSyncOptions) {
const store = getPeriodicSyncTagStore();
const existing = await store.get(tag);
const isFiring = existing?.registrationState === "firing"
Expand All @@ -57,7 +61,8 @@ export class DurablePeriodicSyncManager {
createdAt: existing?.createdAt || registeredAt,
registeredAt,
registrationState,
registrationStateAt: registeredAt
registrationStateAt: registeredAt,
...options
});
}

Expand Down

0 comments on commit fa2195b

Please sign in to comment.