Add pricing entry flow and platform admin foundations
This commit is contained in:
@@ -16,21 +16,33 @@ class RealtimeService {
|
||||
required void Function(RecordSubscriptionEvent) onEvent,
|
||||
}) {
|
||||
UnsubFn? cancel;
|
||||
bool disposeRequested = false;
|
||||
bool disposed = false;
|
||||
|
||||
_pb.collection(collection).subscribe(topic, onEvent, filter: filter).then((fn) {
|
||||
_pb
|
||||
.collection(collection)
|
||||
.subscribe(topic, onEvent, filter: filter)
|
||||
.then((fn) async {
|
||||
if (disposeRequested) {
|
||||
disposed = true;
|
||||
await fn();
|
||||
return;
|
||||
}
|
||||
cancel = fn;
|
||||
});
|
||||
}).catchError((_) {});
|
||||
|
||||
return () async {
|
||||
if (disposed) return;
|
||||
disposeRequested = true;
|
||||
try {
|
||||
final fn = cancel;
|
||||
if (fn != null) {
|
||||
disposed = true;
|
||||
await fn();
|
||||
} else {
|
||||
await _pb.collection(collection).unsubscribe(topic);
|
||||
}
|
||||
} catch (_) {
|
||||
await _pb.collection(collection).unsubscribe(topic);
|
||||
// swallow — never globally unsubscribe the topic here, because
|
||||
// other screens may still be subscribed to the same collection/topic.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user