Skip to content

Commit

Permalink
chore: clean up comments and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-lednev committed Nov 23, 2024
1 parent 6705b50 commit e960b2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/util/create-hooks.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type PointerDateTime = Writable<{
type?: "dateTime" | "date" | undefined;
}>;

function useTasks(props: {
export function useTasks(props: {
settingsStore: Writable<DayPlannerSettings>;
combinedIcalSyncTrigger: Readable<object>;
debouncedTaskUpdateTrigger: Readable<object>;
Expand All @@ -71,6 +71,7 @@ function useTasks(props: {
visibleDays: Readable<Moment[]>;
layoutReady: Readable<boolean>;
dataviewFacade: DataviewFacade;
// todo: replace with metadata cache
app: App;
dataviewSource: Readable<string>;
currentTime: Readable<Moment>;
Expand Down Expand Up @@ -210,6 +211,7 @@ function useTasks(props: {
tasksForToday,
currentTime,
});

return {
tasksWithActiveClockProps,
getDisplayedTasksWithClocksForTimeline,
Expand Down
11 changes: 4 additions & 7 deletions src/util/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const cancelJob =
clearTimeout(id);
});

/**
* A scheduler accepts a list of tasks (a batch) and reports back when all of them are done.
* If a new batch of tasks is added, the scheduler will discard the previous batch and run the new one.
*/
export function createBackgroundBatchScheduler<T>(
onFinish: (results: T[]) => void,
) {
Expand All @@ -54,13 +58,6 @@ export function createBackgroundBatchScheduler<T>(
if (tasks.length > 0) {
currentTaskHandle = enqueueJob(runTaskQueue);
} else {
performance.mark("batch-end");
// const { duration } = performance.measure(
// "batch",
// "batch-start",
// "batch-end",
// );

onFinish(results);
currentTaskHandle = null;
}
Expand Down

0 comments on commit e960b2b

Please sign in to comment.