-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Migrate FetchAndActivate from deprecated implementation #5617
Conversation
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.
LGTM, one question.
// Pass along the fetch error e.g. throttled. | ||
completionHandler(status, error); | ||
if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !fetchError) { | ||
[strongSelf activateWithCompletionHandler:^(NSError *_Nullable activateError) { |
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.
👍
FIRRemoteConfigFetchAndActivateStatus status = | ||
activateError ? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData | ||
: FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote; | ||
completionHandler(status, fetchError); |
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.
Should we use activateError
instead of fetchError
here?
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.
Maybe, but fetchError
matches the previous behavior and changing it would be a breaking change.
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.
If I read the code correctly, fetchError
is nil
here, so can we just pass nil
?
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.
Yep - good catch. Thanks!
@@ -236,27 +236,28 @@ - (void)fetchAndActivateWithCompletionHandler: | |||
(FIRRemoteConfigFetchAndActivateCompletion)completionHandler { | |||
__weak FIRRemoteConfig *weakSelf = self; | |||
FIRRemoteConfigFetchCompletion fetchCompletion = | |||
^(FIRRemoteConfigFetchStatus fetchStatus, NSError *error) { | |||
^(FIRRemoteConfigFetchStatus fetchStatus, NSError *fetchError) { |
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.
This method is a great candidate to be refactored with Promises. We can consider it for future PRs.
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.
Agreed! This and several other RC methods.
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.
LGTM and maybe also wait on @karenyz to give a final look.
}]; | ||
} else if (completionHandler) { | ||
FIRRemoteConfigFetchAndActivateStatus status = | ||
fetchStatus == FIRRemoteConfigFetchStatusSuccess |
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.
is it possible that the fetchStatus is successful and fetchError also exists?
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.
Yes - if the config didn't change. See #3586. I'm planning to deprecate that API and add a new API that returns a bool like Android and JS instead of an error - after I get some integration test infra set up.
// Pass along the fetch error e.g. throttled. | ||
completionHandler(status, error); | ||
if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !fetchError) { | ||
[strongSelf activateWithCompletionHandler:^(NSError *_Nullable activateError) { |
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.
nice! it's odd that it was using sync method even tho this async method exists.
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.
thanks for doing this!
Migrate
fetchAndActivateWithCompletionHandler:
implementation from using the deprecatedactivateFetched
API to the asyncactivateWithCompletionHandler:
Working on integration tests, I was getting a deadlock in
activateFetched
so thought it would be good to move this forward.