mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-11 12:27:50 +01:00
NoteRepository.bulkUpdate sets status/priority on many notes in one store write (mergeLogs + replaceAll; only changed fields plus updated_at get a clock). saveReplacing saves one note and tombstones others in one write. assignToRepo moves plain notes into the repo's open note as "## title" sections via addRepoTask, demoting body headings below "##" so a template note stays one section; notes already in a repo are refused. The seeded watch stream moved to log_watch.dart for the 250-line cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWXdsB7CQPNXVN829G1
23 lines
778 B
Dart
23 lines
778 B
Dart
/// A seeded stream over the note log's change events.
|
|
library;
|
|
|
|
import 'dart:async';
|
|
|
|
/// A stream that emits `compute()` synchronously when first listened to (the
|
|
/// seed), then again on every event of [changes]. Seeding in `onListen` --
|
|
/// rather than lazily in an `async*` body -- avoids a race where a write
|
|
/// between `listen` and the first generator tick would swallow the initial
|
|
/// snapshot.
|
|
Stream<T> watchLog<T>(Stream<void> changes, T Function() compute) {
|
|
StreamSubscription<void>? sub;
|
|
late final StreamController<T> controller;
|
|
controller = StreamController<T>(
|
|
onListen: () {
|
|
controller.add(compute());
|
|
sub = changes.listen((_) => controller.add(compute()));
|
|
},
|
|
onCancel: () => sub?.cancel(),
|
|
);
|
|
return controller.stream;
|
|
}
|