add finalizer to cancel stream subscription when all references to an instance of ElectrumX becomes inaccessible

This commit is contained in:
julian 2023-09-07 12:27:19 -06:00
parent 9c648affe8
commit 67beaf21cd

View file

@ -77,6 +77,11 @@ class ElectrumX {
final Duration connectionTimeoutForSpecialCaseJsonRPCClients;
// add finalizer to cancel stream subscription when all references to an
// instance of ElectrumX becomes inaccessible
static final Finalizer<ElectrumX> _finalizer = Finalizer(
(p0) => p0._torStatusListener?.cancel(),
);
StreamSubscription<TorStatusChangedEvent>? _torStatusListener;
ElectrumX({