withScene<T> method

Future<T> withScene<T>(
  1. Future<T> use(
    1. SemanticScene scene
    ), {
  2. SceneDetail detail = SceneDetail.full,
})

The single perceive entry: read the scene, semanticize, enrich to detail, hand it to use, then dispose. Callers never re-assemble the pipeline themselves.

Implementation

Future<T> withScene<T>(
  Future<T> Function(SemanticScene scene) use, {
  SceneDetail detail = SceneDetail.full,
}) async {
  CallProgress.enter('reading the scene', key: 'read');
  if (await active?.notResumed() case final lifecycle?) throw AppNotResumedError(lifecycle);
  final scene = await reader.readSummary();
  try {
    return await use(await semanticize(scene, detail: detail));
  } finally {
    await scene.dispose();
  }
}