Skip to content

CustomerInfoManager: post notification when CustomerInfo changes#2057

Closed
NachoSoto wants to merge 1 commit into
mainfrom
notification-subscriptions-changed
Closed

CustomerInfoManager: post notification when CustomerInfo changes#2057
NachoSoto wants to merge 1 commit into
mainfrom
notification-subscriptions-changed

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

This will be used for #2007.

@NachoSoto NachoSoto requested a review from a team November 15, 2022 18:15
@NachoSoto NachoSoto force-pushed the notification-subscriptions-changed branch from 3eddf69 to 2f68cc7 Compare November 15, 2022 19:14
@NachoSoto NachoSoto force-pushed the notification-subscriptions-changed branch 2 times, most recently from eca596c to bbec345 Compare November 23, 2022 19:02

@aboedo aboedo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think there could be cases where we're not invalidating correctly

Comment thread Sources/Identity/CustomerInfoManager.swift Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious about this, why don't we reuse this mechanism for getting notified about changes, instead of adding the notificationCenter notification?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For one because this was checking only when active subscriptions changed.
Now that I'm changing the cache invalidation to checking CustomerInfo changes we could.

However, this is used by #2007. Using a notification makes it a lot simpler so that we don't have to manually couple TrialOrIntroPriceEligibilityChecker to CustomerInfoManager. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bump @aboedo
I addressed your comments 10 days ago.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the part that I find a bit concerning is that we have 2 things updating from a change in customerInfo, but we don't have much control over the ordering.
if we're using this for cache invalidation, doesn't it mean that it's possible that you have a closure coming in from here that uses an outdated cache of intro eligibility values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The 2 sources is a valid concern. I think they serve different purposes though.
The notification pattern is useful for 1-N notifications without strongly coupling types, and it simplifies the hierarchy. The current dependency injection approach is prone to retain cycles and leaks as exposed in the other PRs.

As for ordering, I'm not sure that's an issue in this case. Not sure what you mean exactly. #2007 won't recreate the eligibility, simply invalidate the cache for the next time it's requested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Bump @aboedo.

@NachoSoto NachoSoto changed the title CustomerInfoManager: post notification when CustomerInfo subscriptions change CustomerInfoManager: post notification when CustomerInfo changes Nov 26, 2022
@NachoSoto NachoSoto force-pushed the notification-subscriptions-changed branch from bbec345 to a9938b8 Compare November 26, 2022 00:21
@NachoSoto

Copy link
Copy Markdown
Contributor Author

Updated this to post a notification any time CustomerInfo changes.

@NachoSoto NachoSoto requested review from a team and aboedo November 28, 2022 16:09
@NachoSoto

Copy link
Copy Markdown
Contributor Author

Bump @aboedo

@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.

LGTM!

@NachoSoto NachoSoto force-pushed the notification-subscriptions-changed branch from a9938b8 to 376e162 Compare December 20, 2022 22:39
@NachoSoto NachoSoto added the WIP label Jan 5, 2023
@NachoSoto

Copy link
Copy Markdown
Contributor Author

Closing this, will replace #2007 with using the existing observation methods.

@NachoSoto NachoSoto closed this Jan 5, 2023
@NachoSoto NachoSoto deleted the notification-subscriptions-changed branch May 26, 2023 17:19
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.

3 participants