v6: GooglePay - Launch GooglePay#2610
v6: GooglePay - Launch GooglePay#2610ozgur00 wants to merge 2 commits intochore/factory-applicationfrom
Conversation
Summary of ChangesHello @ozgur00, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates Google Pay functionality into the application's UI layer by introducing a dedicated Composable function. This new component streamlines the process of initiating Google Pay transactions and processing their outcomes, enhancing the user experience for payment flows. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a composable googlePayEvent to handle launching Google Pay from a Compose UI. The implementation looks good, but I have a suggestion to improve the robustness and performance of the LaunchedEffect within the new composable. My feedback focuses on making the side effect handling more stable and ensuring future changes to event types are caught at compile time.
| LaunchedEffect(viewEventFlow, onPaymentResult) { | ||
| viewEventFlow.collect { event -> | ||
| when (event) { | ||
| is GooglePayViewEvent.LaunchGooglePay -> { | ||
| googlePayLauncher.launch(event.task) | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I have a couple of suggestions for this LaunchedEffect block:
-
LaunchedEffectkey: TheonPaymentResultcallback is included as a key. Since lambdas from callers are not guaranteed to be stable, this can cause the effect to be cancelled and restarted on every recomposition. This would lead to re-collecting theviewEventFlow, which can cause issues like missing events. SinceonPaymentResultis not used inside theLaunchedEffectblock, it should be removed from the keys. TherememberLauncherForActivityResultalready handles updating its callback correctly on recompositions. -
Non-exhaustive
when: Thewhenstatement onGooglePayViewEventis not exhaustive because it's used as a statement. If new event types are added to theGooglePayViewEventsealed class in the future, the compiler won't enforce handling them, and they will be silently ignored at runtime. To prevent this, you can usewhenas an expression to enforce compile-time checking for all cases.
Here is a suggestion that applies both changes:
LaunchedEffect(viewEventFlow) {
viewEventFlow.collect { event ->
@Suppress("UNUSED_VARIABLE")
val exhaustiveWhen = when (event) {
is GooglePayViewEvent.LaunchGooglePay -> {
googlePayLauncher.launch(event.task)
}
}
}
}
✅ No public API changes |
|


Description
Add a googlePayEvent composable for launching google pay.
Checklist
Ticket Number
COSDK-936