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

StringValue and BinaryValue is confusing/ugly #69

Closed
anitarua opened this issue Jan 5, 2024 · 1 comment
Closed

StringValue and BinaryValue is confusing/ugly #69

anitarua opened this issue Jan 5, 2024 · 1 comment
Assignees
Labels
dart for dart sdk

Comments

@anitarua
Copy link
Collaborator

anitarua commented Jan 5, 2024

Dart doesn't support overloading, but is there another way people can provide strings or binary values directly to api methods instead of first creating StringValue or BinaryValue?

Or possibly just make keys accept only strings for now and let values by StringValue or BinaryValue

Can ping Chris for more details/ideas on how to handle this

@anitarua anitarua added the dart for dart sdk label Jan 5, 2024
@anitarua
Copy link
Collaborator Author

anitarua commented Jan 10, 2024

Alternative for function overloading: optional parameters. Can't have parameters with the same name, though, even if they're different types, so it would still be a signature like get(String cacheName, {String? stringKey, List<int>? binaryKey})

Alternative for type unions: use the dynamic type. We can take an approach similar to the Swift SDK where the public-facing CacheClient accepts string and binary values directly but the internal data client accepts only StringValue or BinaryValue.
--> Turns out this is NOT an idiomatic Dart approach

Or we go the current route which is similar to the Go sdk where users have to construct StringValue or BinaryValue before passing items in.

Seems like the most idiomatic approach would be to create one method for each specific operation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart for dart sdk
Projects
None yet
Development

No branches or pull requests

1 participant