@@ -572,7 +572,6 @@ class UpdateMachine {
572
572
final result = await getEvents (store.connection,
573
573
queueId: queueId, lastEventId: lastEventId);
574
574
// TODO handle errors on get-events; retry with backoff
575
- // TODO abort long-poll and close ApiConnection on [dispose]
576
575
final events = result.events;
577
576
for (final event in events) {
578
577
store.handleEvent (event);
@@ -591,7 +590,6 @@ class UpdateMachine {
591
590
// TODO(#322) save acked token, to dedupe updating it on the server
592
591
// TODO(#323) track the registerFcmToken/etc request, warn if not succeeding
593
592
Future <void > registerNotificationToken () async {
594
- // TODO call removeListener on [dispose]
595
593
NotificationService .instance.token.addListener (_registerNotificationToken);
596
594
await _registerNotificationToken ();
597
595
}
@@ -602,6 +600,10 @@ class UpdateMachine {
602
600
await NotificationService .registerToken (store.connection, token: token);
603
601
}
604
602
603
+ void dispose () { // TODO abort long-poll and close ApiConnection
604
+ NotificationService .instance.token.removeListener (_registerNotificationToken);
605
+ }
606
+
605
607
@override
606
608
String toString () => '${objectRuntimeType (this , 'UpdateMachine' )}#${shortHash (this )}' ;
607
609
}
0 commit comments