Support multiple UpdatedCustomerInfoListeners#3247
Draft
facumenzella wants to merge 6 commits intomainfrom
Draft
Support multiple UpdatedCustomerInfoListeners#3247facumenzella wants to merge 6 commits intomainfrom
facumenzella wants to merge 6 commits intomainfrom
Conversation
Add add/remove methods for registering multiple UpdatedCustomerInfoListener instances, deprecate the single-listener property setter, and expose the new API through PurchasesType so the UI module can use it. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Resolve conflict in MockPurchasesType.kt — keep new listener methods. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add missing mockk stubs for addUpdatedCustomerInfoListener, removeUpdatedCustomerInfoListener, and removeAllListeners. Update test that verified the old close() behavior (setting listener to null) to verify removeAllListeners() instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Merge duplicate `if (lastSent != customerInfo)` checks in notifyListeners - Guard sendToSingleListener against overwriting lastSentCustomerInfo with stale data - Only track diagnostics in sendToSingleListener when info differs from last sent Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…istener support - Remove lastSentCustomerInfo mutation from sendToSingleListener to prevent rolling back the global dedup gate to a stale value, which could cause double-delivery to all existing listeners on the next notifyListeners call - Move listeners.add() to after the initial cached-info dispatch so a concurrent notifyListeners cannot interleave a newer value before the new listener's initial delivery, preventing out-of-order delivery on the main thread Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…sting ones Covers the fix to sendToSingleListener that prevented it from rolling back lastSentCustomerInfo to a stale value, which would cause re-delivery to all existing listeners on the next notifyListeners call. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
addUpdatedCustomerInfoListener/removeUpdatedCustomerInfoListener(listener)methods to support multiple concurrent listeners inCustomerInfoUpdateHandler,PurchasesOrchestrator, and bothPurchasesflavorsupdatedCustomerInfoListenerproperty and no-argremoveUpdatedCustomerInfoListener()PurchasesType/PurchasesImpl/MockPurchasesTypeso the UI module can register its own listenerThis is infrastructure-only — Customer Center ViewModel integration is a follow-up.
Fixes in
sendToSingleListener/addUpdatedCustomerInfoListenersendToSingleListenerno longer mutateslastSentCustomerInfo: the shared dedup gate must only be advanced bynotifyListeners. Previously, registering a new listener while the cache held an older value than what was last broadcast would roll the gate backwards, causing double-delivery to all existing listeners on the nextnotifyListenerscall.listeners.add()moved to after the initial cached-info dispatch: prevents a concurrentnotifyListenersfrom interleaving a newer value before the new listener's initial delivery, which would leave it in a stale state.Test plan
CustomerInfoUpdateHandlerTest— 8 new test cases covering:removeAllListenersclears everything@Suppress("DEPRECATION")on legacy usagesapi-dump.sh🤖 Generated with Claude Code