-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop proxy binary messenger #715
Conversation
- Adopt Pigeon message channel suffix instead of own custom proxy binary messenger
f2ff4b7
to
593a58a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There some aspects to improve, mainly when it comes to multi-instance scenarios, but looking good overall.
android/src/main/kotlin/com/mapbox/maps/mapbox_maps/EventHandler.kt
Outdated
Show resolved
Hide resolved
style = StyleManager(binaryMessenger: messenger); | ||
_mapEvents = _MapEvents(binaryMessenger: messenger); | ||
_snapshotterMessenger = | ||
_SnapshotterMessenger(messageChannelSuffix: _suffix.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a pattern where binary messenger is specified explicitly, for consistency it should be specified here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is necessary, as stated by the doc, so we can leave it as optional null
The [binaryMessenger] named argument is available for dependency injection. If it is left null, the default BinaryMessenger will be used which routes to the host platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not having it works for me as well, as long as it is consistent through the code base.
Currently, we still have binaryMessenger parameter specified in some places.
lib/src/map_events.dart
Outdated
_MapEvents({BinaryMessenger? binaryMessenger}) { | ||
_channel = MethodChannel('com.mapbox.maps.flutter.map_events', | ||
const StandardMethodCodec(), binaryMessenger); | ||
_MapEvents({BinaryMessenger? binaryMessenger, String channelSuffix = ''}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally binary messenger should be a required parameter as well, since in all other places binary messenger is specified explicitly, having it as a requirement will help with consistency.
arguments: args, | ||
channelSuffix: args["channelSuffix"] as? Int ?? 0, | ||
registrar: registrar, | ||
pluginVersion: pluginVersion, | ||
eventTypes: eventTypes | ||
pluginVersion: args["mapboxPluginVersion"] as? String ?? "", | ||
eventTypes: args["eventTypes"] as? [Int] ?? [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if these fallback values (0, "", []) are used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the same as before 😅 this one is only clean up the code a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my side. I think ready to go once we get @evil159 's approval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maios thank you for addressing the feedback. I think we are almost there, I have left a couple of nits(in my opinion the binary messenger parameter should be removed), and I noticed there is one method channel in _MapboxMapsPlatform
lacking the channel suffix.
Otherwise, it's looking very good!
P.S. This is an internal change, but its impact is broad. Should we note it in the changelog?
style = StyleManager(binaryMessenger: messenger); | ||
_mapEvents = _MapEvents(binaryMessenger: messenger); | ||
_snapshotterMessenger = | ||
_SnapshotterMessenger(messageChannelSuffix: _suffix.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not having it works for me as well, as long as it is consistent through the code base.
Currently, we still have binaryMessenger parameter specified in some places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
@maios -- I think the Should this be |
What does this pull request do?
Drop
ProxyBinaryMessenger
, instead, setup channel with a messageChannelSuffix which is now supported by PigeonWhat is the motivation and context behind this change?
Pull request checklist: