Quellcode durchsuchen

ensure only update property wrapper when activate is true

Charlotte Liang vor 3 Jahren
Ursprung
Commit
8c0dfe027d

+ 2 - 2
FirebaseRemoteConfigSwift/Apps/SwiftUISample/SwiftUISample/ContentView.swift

@@ -24,7 +24,7 @@ struct Recipe : Decodable {
 }
 
 struct ContentView: View {
-  @RemoteConfigProperty(key: "Color", placeholder: "blue") var configValue : String
+  @RemoteConfigProperty(key: "Color", placeholder: "blue") var colorValue : String
   @RemoteConfigProperty(key: "Toggle", placeholder: false) var toggleValue : Bool
   @RemoteConfigProperty(key: "fruits", placeholder: []) var fruits : [String]
   @RemoteConfigProperty(key: "counter", placeholder: 1) var counter : Int
@@ -34,7 +34,7 @@ struct ContentView: View {
   var body: some View {
     VStack {
       ForEach(0 ... counter, id: \.self) { i in
-            Text(configValue)
+            Text(colorValue)
               .padding()
             .foregroundStyle(toggleValue ? .primary : .secondary)}
       

+ 1 - 1
FirebaseRemoteConfigSwift/Sources/PropertyWrapper/RemoteConfigValueObservable.swift

@@ -47,7 +47,7 @@ internal class RemoteConfigValueObservable<T: Decodable>: ObservableObject {
         return
       }
       self.remoteConfig.activate { changed, error in
-        guard error == nil else {
+        guard error == nil && changed else {
           return
         }
         DispatchQueue.main.async {