Skip to content

Commit f0c76da

Browse files
gnpricechrisbobbe
authored andcommitted
store: Implement UpdateMachine.dispose
1 parent fcb05a4 commit f0c76da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/model/store.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,6 @@ class UpdateMachine {
572572
final result = await getEvents(store.connection,
573573
queueId: queueId, lastEventId: lastEventId);
574574
// TODO handle errors on get-events; retry with backoff
575-
// TODO abort long-poll and close ApiConnection on [dispose]
576575
final events = result.events;
577576
for (final event in events) {
578577
store.handleEvent(event);
@@ -591,7 +590,6 @@ class UpdateMachine {
591590
// TODO(#322) save acked token, to dedupe updating it on the server
592591
// TODO(#323) track the registerFcmToken/etc request, warn if not succeeding
593592
Future<void> registerNotificationToken() async {
594-
// TODO call removeListener on [dispose]
595593
NotificationService.instance.token.addListener(_registerNotificationToken);
596594
await _registerNotificationToken();
597595
}
@@ -602,6 +600,10 @@ class UpdateMachine {
602600
await NotificationService.registerToken(store.connection, token: token);
603601
}
604602

603+
void dispose() { // TODO abort long-poll and close ApiConnection
604+
NotificationService.instance.token.removeListener(_registerNotificationToken);
605+
}
606+
605607
@override
606608
String toString() => '${objectRuntimeType(this, 'UpdateMachine')}#${shortHash(this)}';
607609
}

0 commit comments

Comments
 (0)