Skip to content

drainSync — @gj-kit/expo-workouts

A public function from @gj-kit/expo-workouts/testing. The signature below is taken directly from the 0.1.1 release declaration.

import { drainSync } from '@gj-kit/expo-workouts/testing';
/**
* Run the full sync loop to convergence against any `WorkoutsApi`. Test helper only — it holds the
* whole store in memory and does NOT model the one-transaction rule, so a production app must write
* the loop itself. `killAfterPages` reproduces a crash and reports whether the cursor was persisted
* without the items, which is the one failure the library cannot prevent.
*/
declare function drainSync(api: Pick<WorkoutsApi, 'syncWorkouts' | 'listWorkouts'>, opts: {
readonly backfillFromMs: number;
readonly cursor?: WorkoutsSyncCursor | null | undefined;
readonly maxPages?: number | undefined;
readonly killAfterPages?: number | undefined;
}): Promise<{
readonly cursor: WorkoutsSyncCursor;
readonly store: ReadonlyMap<string, Workout>;
readonly pages: number;
readonly resets: readonly CursorResetReason[];
}>;

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/expo-workouts
  • Version: 0.1.1
  • Public entry: ./testing
  • Source: GitHub