Creating a new `anchoredObjectQuery` stream cancels the previous one
opsb opened this issue · 1 comments
Describe the bug
When you call HealthKitReporter.anchoredObjectQuery
and then later call it again to create a new anchoredObjectQuery the original one is cancelled.
To Reproduce
Steps to reproduce the behavior:
var originalStream = HealthKitReporter.anchoredObjectQuery(...);
var newStream = HealthKitReporter.anchoredObjectQuery(...); // cancels originalStream
Expected behavior
You should be able to create any number of anchoredObjectQuerys that run as independent streams.
Additional context
A single AnchoredObjectQueryStreamHandler
is registered with the event channel at https://github.com/VictorKachalov/health_kit_reporter/blob/master/ios/Classes/SwiftHealthKitReporterPlugin.swift#L69. AnchoredObjectQueryStreamHandler
only has a single query
though which is replaced at https://github.com/VictorKachalov/health_kit_reporter/blob/master/ios/Classes/AnchoredObjectQueryStreamHandler.swift#L36 whenever HealthKitReporter.anchoredObjectQuery
is called.
I'm new to Flutter/Dart so I'm not sure how this tends to be handled but in other languages using channels I've used an identifier (say a uuid) for the stream that is created for a particular call to HealthKitReporter.anchoredObjectQuery
. That way it's possible to have multiple AnchoredQueries on the Swift side and use the uuid to route messages appropriately on the Dart side.
Hi @opsb
I merged your PR, but on a separate branch (1.1.2-prenullsafety), since the package you use there is quite old and not updated to nullsafety, I would not include the code in final 1.3.0 version which will have the concept of nullsafety first.
I fixed some issues releated to overwriting the subs by tracking queries, you may check how it works on master branch