0c6e3eaa93
* Support searching for deck configs by name * Integrate FSRS optimizer into Anki * Hack in a rough implementation of evaluate_weights() * Interrupt calculation if user closes dialog * Fix interrupted error check * log_loss/rmse * Update to latest fsrs commit; add progress info to weight evaluation * Fix progress not appearing when pretrain takes a while * Update to latest commit
21 lines
623 B
TypeScript
21 lines
623 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import type { Progress } from "@tslib/anki/collection_pb";
|
|
import { latestProgress } from "@tslib/backend";
|
|
|
|
export async function runWithBackendProgress<T>(
|
|
callback: () => Promise<T>,
|
|
onUpdate: (progress: Progress) => void,
|
|
): Promise<T> {
|
|
const intervalId = setInterval(async () => {
|
|
const progress = await latestProgress({});
|
|
onUpdate(progress);
|
|
}, 100);
|
|
try {
|
|
return await callback();
|
|
} finally {
|
|
clearInterval(intervalId);
|
|
}
|
|
}
|