beerstorm-net / GeoFlutterFire2

🔥GeoFlutterFire2🔥 is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://pub.dev/packages/geoflutterfire2
MIT License
14 stars 40 forks source link

Possibility to get direct rxdart stream to avoid memory leaks #26

Closed pawlowskim closed 1 year ago

pawlowskim commented 1 year ago

Possibility to use the library without memory leak that is caused by not cancelling stream subscriptions for merged streams from rxdart. No breaking changes, I kept current behaviour so to not break it work users.

Basically, creating broadcast stream and cancelling it does not nothing on the stream controller which is created in rxdart: https://github.com/dart-lang/sdk/issues/26686#issuecomment-225346901

The other way to fix it would be extend rxdart about possibility to return stream controller, and return both, broadcast stream and controller so user have full control over what is going down the path. But this could be overkill, and requires rxdart changes (tested that solution already). But, anyway, since we need to change the geo hash center position to start listening for different region, I would suggest using stream from rxdart directly. The only thing that above is doesn't suits is when user need to have listener in couple places (different views for instance). But this also could be done by user by have single central place of the stream consumer.

river2202 commented 1 year ago

+1

bcbcbcbcbcl commented 1 year ago

This is required to cancel the old subscription when update center position or radius & can prevent high read usage on Firestore due to memory leak.

FloLecoeuche commented 1 year ago

@zeusbaba can you review this PR ?

zeusbaba commented 1 year ago

Thanks for your contributions. i'll merge this PR now, thereafter make a new release soon

just published v2.3.15