Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Switch to KVO for configuration values #95

Merged
merged 3 commits into from
Dec 12, 2019
Merged

Switch to KVO for configuration values #95

merged 3 commits into from
Dec 12, 2019

Conversation

rclee
Copy link
Contributor

@rclee rclee commented Dec 11, 2019

This should reduce the amount of callbacks we get from NSUserDefaults changes.

@rclee rclee requested review from alfwatt, julianrex and a team December 11, 2019 02:25
@rclee rclee self-assigned this Dec 11, 2019
Copy link
Contributor

@julianrex julianrex left a comment

Choose a reason for hiding this comment

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

This looks great! thank you - just a couple of minor tweaks needed I think.

Comment on lines 105 to 106
@catch (NSException *exception) {} //Purposefully unhandled. This should only fail if we are unable to add an observer in the first place.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does/can this happen?

Copy link
Contributor Author

@rclee rclee Dec 11, 2019

Choose a reason for hiding this comment

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

It's unlikely. But if, for example, another class were to observe this same parameter and removed the observer and then we tried to remove the same observer a second time in this class then it could cause a crash. Since we're setting this at init and only use these keys within this class; I don't think it should happen but I just wanted to add it as a precaution (even if it is an unnecessary one).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previous code comment probably wouldn't happen. I cleaned the comment up with the more realistic scenario as well.

platform/ios/src/MGLMapboxEvents.m Show resolved Hide resolved
platform/ios/src/MGLMapboxEvents.m Show resolved Hide resolved
@rclee rclee requested a review from julianrex December 11, 2019 19:19
Copy link
Contributor

@alfwatt alfwatt left a comment

Choose a reason for hiding this comment

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

Approved with the exception reporting suggestion

@julianrex julianrex merged commit f08955e into master Dec 12, 2019
@julianrex julianrex deleted the rclee-kvo branch December 12, 2019 16:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants