Skip to content

feat: pass Decodable struct to flag evaluation #191

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nicklasl
Copy link
Member

@nicklasl nicklasl commented Apr 3, 2025

This PR introduces

a significant enhancement to the Confidence SDK for Swift by adding support for passing Decodable structs directly to flag evaluation. The main changes include:

API Methods:

  • Updated getEvaluation<T: Decodable>(key: String, defaultValue: T) method that allows passing a Codable struct as context
  • Updated getValue<T: Decodable>(key: String, defaultValue: T) method for direct value retrieval with context

Type Safety:

This provides better compile-time checking and IDE support compared to the dictionary-based approach

Backward Compatibility:

All existing methods continue to work as before since ConfidenceValue's are Codeable.

This enhancement makes the SDK more Swift-idiomatic by:

  • Leveraging Swift's type system more effectively
  • Providing better developer experience with compile-time type checking
  • Making it easier to work with structured data in flag evaluations
  • Reducing the need for manual conversion between structs and dictionaries

The changes are particularly useful for developers who want to:

  • Pass strongly-typed context data to flag evaluations
  • Work with complex data structures in their flag evaluations
  • Maintain type safety throughout their flag evaluation code

Open questions

  • How do we handle when there's a mis match between flag struct and the decodable struct?

@nicklasl nicklasl changed the title feat: pass codable struct to flag evaluation feat: pass Decodable struct to flag evaluation Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant