Skip to content

Remove side effect from setting purchasesUpdatedListener#1443

Merged
vegaro merged 2 commits into
mainfrom
cesar/sdk-3278-improve-billingwrapper-retry-mechanism_2_remove_side_effect
Nov 7, 2023
Merged

Remove side effect from setting purchasesUpdatedListener#1443
vegaro merged 2 commits into
mainfrom
cesar/sdk-3278-improve-billingwrapper-retry-mechanism_2_remove_side_effect

Conversation

@vegaro

@vegaro vegaro commented Nov 7, 2023

Copy link
Copy Markdown
Member

I removed a side effect on setting purchasesUpdatedListener. I don't think we should be starting/ending the connection there and we should do it independently

@vegaro vegaro added the refactor label Nov 7, 2023
@vegaro vegaro requested a review from a team November 7, 2023 13:58

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. Have you tested the case of closing purchases then configuring again? We only reset the listener when closing purchases, so it's the only point where I think it could be problematic. Not sure how many people use that, but might be good to confirm it reconnects ok.


every {
startConnectionOnMainThread()
} just runs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total nitpick, but I've been using Runs (uppercase) instead of runs. Do you have any preference?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I have no preference, I will change it to the uppercase version 😄

@codecov

codecov Bot commented Nov 7, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.09%. Comparing base (6311b24) to head (fbd2b47).
Report is 317 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1443      +/-   ##
==========================================
- Coverage   84.13%   84.09%   -0.05%     
==========================================
  Files         197      197              
  Lines        6649     6644       -5     
  Branches      965      964       -1     
==========================================
- Hits         5594     5587       -7     
+ Misses        684      683       -1     
- Partials      371      374       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vegaro

vegaro commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

I think this makes sense. Have you tested the case of closing purchases then configuring again? We only reset the listener when closing purchases, so it's the only point where I think it could be problematic. Not sure how many people use that, but might be good to confirm it reconnects ok.

I haven't tested it, I will. I noticed though, that the close function does call endConnection after setting the listener to null, so I don't think there's any difference there:

fun close() {
        purchasesUpdatedListener = null
        endConnection()
}

Before this change, we were actually calling endConnection twice when calling close (one when setting the listener to null as a side effect and one directly in close)

@vegaro

vegaro commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

It works @tonidero , I configured, then ended connection then configured and it works fine

@vegaro vegaro merged commit 250777a into main Nov 7, 2023
@vegaro vegaro deleted the cesar/sdk-3278-improve-billingwrapper-retry-mechanism_2_remove_side_effect branch November 7, 2023 19:25
NachoSoto added a commit that referenced this pull request Nov 8, 2023
**This is an automatic release.**

### RevenueCatUI
* `PaywallActivityLauncher`: new constructor for a generic
`ActivityResultCaller` (#1441) via NachoSoto (@NachoSoto)
* Improve fullscreen templates in landscape orientation (#1435) via Toni
Rico (@tonidero)
* `Paywalls`: improve Japanese localization (#1439) via NachoSoto
(@NachoSoto)
### Other Changes
* Remove side effect from setting purchasesUpdatedListener (#1443) via
Cesar de la Vega (@vegaro)
* Paywalls: Store paywall events on disk and API (1) (#1436) via Toni
Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants