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

[Config] Add encoder and decoder param to public codable APIs #14525

Merged
merged 6 commits into from
Mar 6, 2025
Merged

Conversation

ncooke3
Copy link
Member

@ncooke3 ncooke3 commented Mar 4, 2025

Fix #14368

Relevant: #9084 (comment)

I did not update the following APIs because I wasn't able to get a test case working (See be0616a). I think it's reasonable to limit the scope of exposing the FirebaseData*coders in the public API since it needs some re-thinking).

  • func decoded<Value: Decodable>(asType: Value.Type = Value.self) throws -> Value {
    if asType == Date.self {
    throw RemoteConfigValueCodableError
    .unsupportedType("Date type is not currently supported for " +
    " Remote Config Value decoding. Please file a feature request")
    }
    return try FirebaseDataDecoder()
    .decode(Value.self, from: FirebaseRemoteConfigValueDecoderHelper(value: self))
    }
    }
  • /// Return a typed RemoteConfigValue for a key.
    /// - Parameter key: A Remote Config key.
    /// - Returns: A typed RemoteConfigValue.
    subscript<T: Decodable>(decodedValue key: String) -> T? {
    return try? configValue(forKey: key).decoded()
    }

@ncooke3 ncooke3 marked this pull request as ready for review March 5, 2025 14:16
Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

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

LGTM with a short API review document.

@ncooke3 ncooke3 merged commit 8ee1e96 into main Mar 6, 2025
47 checks passed
@ncooke3 ncooke3 deleted the nc/14368 branch March 6, 2025 23:31
ncooke3 added a commit that referenced this pull request Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FirebaseRemoteConfig issue with Codable default config
3 participants