-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: use type-specific methods in public clients, Value in internal clients #90
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1084fc9
fix: use dynamic in public clients, Value in internal clients
anitarua 9de61a3
dart format
anitarua 16c77f9
fix topics test
anitarua ba68049
Merge branch 'main' into string-binary-values
anitarua bb4cece
Merge branch 'main' into string-binary-values
anitarua 4f139ee
provide String and Binary versions of methods that accept Values on p…
anitarua 3f1edf4
pass Strings directly to doc api examples
anitarua 48b8e68
Merge branch 'main' into string-binary-values
anitarua 48ee796
add missing list collection docstrings
anitarua a3cfc0f
Binary -> Bytes
anitarua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:momento/momento.dart'; | ||
import 'package:momento/src/errors/errors.dart'; | ||
|
||
Value getStringOrBinaryFromDynamic(dynamic value, String parameterName) { | ||
if (value is String) { | ||
return StringValue(value); | ||
} else if (value is List<int>) { | ||
return BinaryValue(value); | ||
} else if (value is Value) { | ||
return value; | ||
} else { | ||
throw InvalidArgumentException( | ||
"$parameterName must be a String or List<int>", null, null); | ||
} | ||
} | ||
|
||
List<Value> getListOfStringOrBinaryFromDynamic( | ||
List<dynamic> values, String parameterName) { | ||
final list = <Value>[]; | ||
for (final value in values) { | ||
list.add(getStringOrBinaryFromDynamic(value, parameterName)); | ||
} | ||
return list; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a really cool thing to try!
I'm guessing the editor isn't able to give any type hints for this at all though? and it would be a runtime error if you just tried to pass in like, some random object type as the argument to one of these dynamic args? If so, lemme noodle on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If type hints are a good trade for an uglier API, we could add the type to the function name like we do with some of the collection methods in Java:
dictionarySetFieldsStringBytes
.