refactor(app): delayed deletions move into halkyon_app (ADR 0030, D24)
Learn's DelayedDeletions, unchanged, with its test, so that Train's workouts can be deleted with an undo as Learn's items are. Learn's deletions import it from halkyon_app now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
dd778cb2cd
commit
39b43217f6
1 changed files with 24 additions and 6 deletions
17
packages/halkyon_app/test/support/eventually.dart
Normal file
17
packages/halkyon_app/test/support/eventually.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// Waits until [condition] holds, checking every few milliseconds, and fails
|
||||
/// after [timeout]: for what follows a real timer, without betting on how
|
||||
/// fast a busy machine runs.
|
||||
Future<void> eventually(
|
||||
bool Function() condition, {
|
||||
Duration timeout = const Duration(seconds: 10),
|
||||
}) async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
while (!condition()) {
|
||||
if (stopwatch.elapsed > timeout) {
|
||||
fail('Still not so after $timeout.');
|
||||
}
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue