Skip to content

Commit d56ecef

Browse files
committed
use time mircosecond instead of counter for subscription id
1 parent 9fc5b59 commit d56ecef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

templates/flutter/lib/src/realtime_mixin.dart.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ mixin RealtimeMixin {
132132
StreamController<RealtimeMessage> controller = StreamController.broadcast();
133133
_channels.addAll(channels);
134134
Future.delayed(Duration.zero, () => _createSocket());
135-
int counter = _subscriptionsCounter++;
135+
int id = DateTime.now().microsecondsSinceEpoch;
136136
RealtimeSubscription subscription = RealtimeSubscription(
137137
controller: controller,
138138
channels: channels,
139139
close: () async {
140-
_subscriptions.remove(counter);
140+
_subscriptions.remove(id);
141141
_subscriptionsCounter--;
142142
controller.close();
143143
_cleanup(channels);
@@ -148,7 +148,7 @@ mixin RealtimeMixin {
148148
await _closeConnection();
149149
}
150150
});
151-
_subscriptions[counter] = subscription;
151+
_subscriptions[id] = subscription;
152152
return subscription;
153153
}
154154

0 commit comments

Comments
 (0)