WorryFree Computers   »   [go: up one dir, main page]

Skip to content
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

Merged
merged 3 commits into from
May 15, 2020

Conversation

paulb777
Copy link
Member
@paulb777 paulb777 commented May 15, 2020

Migrate fetchAndActivateWithCompletionHandler: implementation from using the deprecated activateFetched API to the async activateWithCompletionHandler:

Working on integration tests, I was getting a deadlock in activateFetched so thought it would be good to move this forward.

Copy link
Contributor
@maksymmalyhin maksymmalyhin left a 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) {
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor
@charlotteliang charlotteliang left a 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
Copy link
Contributor

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?

Copy link
Member Author

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) {
Copy link
Contributor

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.

Copy link
Contributor
@karenyz karenyz left a 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!

@paulb777 paulb777 merged commit 4dcf659 into master May 15, 2020
@paulb777 paulb777 deleted the pb-rc-migrate-deprecate branch May 15, 2020 23:47
@firebase firebase locked and limited conversation to collaborators Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants