From 6536d135e3281883f8f0d3b69a1eff93c27f116d Mon Sep 17 00:00:00 2001 From: fuwa Date: Thu, 25 Jul 2019 01:53:57 +0000 Subject: [PATCH] detect exiting in proper loop --- cyberwow/lib/state.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index cf42fbe..cd308f3 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -235,13 +235,6 @@ class SyncedState extends HookedState { await for (final line in processOutput) { if (!synced) break; - if (isExiting()) { - ExitingState _next = ExitingState - ( - setState, getNotification, stdout, processOutput - ); - return moveState(_next); - } // print('synced: print stdout loop'); stdout.addLast(line); log.info(line); @@ -252,6 +245,16 @@ class SyncedState extends HookedState { Future checkSync() async { await for (final _null in refresh.pull(getNotification, 'syncedState')) { + if (isExiting()) { + log.fine('Synced state detected exiting'); + + ExitingState _next = ExitingState + ( + setState, getNotification, stdout, processOutput + ); + return moveState(_next); + } + if (await daemon.isNotSynced()) { synced = false; break;