firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[Feature Proposal]Property Wrapper for RemoteConfig

Open fumito-ito opened this issue 3 years ago • 7 comments

Why

#9828

What

This PR provides a Property Wrapper with DynamicProperty for RemoteConfig. With this feature, users can bind Remote Config values to variables, and at the same time, reflect them in the View of the SwiftUI in real time.

Known Issues

  • The lastFetchTime is monitored to detect that the RemoteConfig value has changed. This is not very accurate. For example, if the defaultValue is changed, the change will not be detected.
  • Only Decodable properties are covered. Therefore, users cannot bind the PropertyWrapper to variables of type Any, such as those provided by jsonValue.

fumito-ito avatar Jun 17 '22 17:06 fumito-ito

Thanks @fumito-ito! Please resolve the CI issues.

paulb777 avatar Jun 17 '22 19:06 paulb777

CI back to green 🙌

fumito-ito avatar Jun 18 '22 07:06 fumito-ito

Thanks! We need to do an internal API review process so it may take us a few weeks to a month to merge, but I expect it to happen.

paulb777 avatar Jun 29 '22 00:06 paulb777

@fumito-ito Thank you for this initiative! I'm looking into the API review right now. Do you have a sample test app or some sample code that I can see how to use this new API to reflect config changes on SwiftUI?

charlotteliang avatar Jul 15 '22 20:07 charlotteliang

Hi! @chliangGoogle thank you for your feedback. The simplest sample is like https://github.com/firebase/firebase-ios-sdk/discussions/9828.

@RemoteConfig(forKey: "is_new_feature_available")
var isNewFeatureAvailable: Bool

Toggle(isOn: isNewFeatureAvailable) {
     Text("wonderful new feature")
}

If you need more sample app, I can upload it into the repository but I cannot find where to put sample apps for remote config. Could you tell me place for sample app ?

fumito-ito avatar Jul 16 '22 17:07 fumito-ito

@fumito-ito The sample code is exactly what I need. No need to make a sample app for this. Thanks!

charlotteliang avatar Jul 19 '22 05:07 charlotteliang

Hey @fumito-ito I'm working on Google Open Source Peer Bonus nominations and would like to recognize your contribution to make Firebase Remote Config more SwiftUI friendly. I couldn't find an email address for you, so if you're interested, please email it to chliang at google.com and I'll make the nomination.

charlotteliang avatar Jul 20 '22 21:07 charlotteliang

Going to close since this PR was incorporated into #10155.

Thanks @fumito-ito for getting this going!

paulb777 avatar Oct 20 '22 20:10 paulb777