Skip to content

Commit 50894b7

Browse files
authored
fix: use type-specific methods in public clients, Value in internal clients (#90)
* fix: use dynamic in public clients, Value in internal clients * dart format * fix topics test * provide String and Binary versions of methods that accept Values on public clients instead of using dynamic * pass Strings directly to doc api examples * add missing list collection docstrings * Binary -> Bytes
1 parent fbbd3d3 commit 50894b7

File tree

11 files changed

+446
-99
lines changed

11 files changed

+446
-99
lines changed

example/doc_example_apis/doc_example_apis.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Future<void> example_API_InstantiateCacheClient() async {
1414
}
1515
}
1616

17-
Future<void> example_API_CreateCache(CacheClient cacheClient, String cacheName) async {
17+
Future<void> example_API_CreateCache(
18+
CacheClient cacheClient, String cacheName) async {
1819
final result = await cacheClient.createCache(cacheName);
1920
switch (result) {
2021
case CreateCacheAlreadyExists():
@@ -36,7 +37,8 @@ Future<void> example_API_ListCaches(CacheClient cacheClient) async {
3637
}
3738
}
3839

39-
Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName) async {
40+
Future<void> example_API_DeleteCache(
41+
CacheClient cacheClient, String cacheName) async {
4042
final result = await cacheClient.deleteCache(cacheName);
4143
switch (result) {
4244
case DeleteCacheError():
@@ -47,7 +49,8 @@ Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName)
4749
}
4850
}
4951

50-
Future<void> example_API_Set(CacheClient cacheClient, String cacheName, Value key, Value value) async {
52+
Future<void> example_API_Set(
53+
CacheClient cacheClient, String cacheName, String key, String value) async {
5154
final result = await cacheClient.set(cacheName, key, value);
5255
switch (result) {
5356
case SetError():
@@ -58,7 +61,8 @@ Future<void> example_API_Set(CacheClient cacheClient, String cacheName, Value ke
5861
}
5962
}
6063

61-
Future<void> example_API_Get(CacheClient cacheClient, String cacheName, Value key) async {
64+
Future<void> example_API_Get(
65+
CacheClient cacheClient, String cacheName, String key) async {
6266
final result = await cacheClient.get(cacheName, key);
6367
switch (result) {
6468
case GetMiss():
@@ -70,7 +74,8 @@ Future<void> example_API_Get(CacheClient cacheClient, String cacheName, Value ke
7074
}
7175
}
7276

73-
Future<void> example_API_Delete(CacheClient cacheClient, String cacheName, Value key) async {
77+
Future<void> example_API_Delete(
78+
CacheClient cacheClient, String cacheName, String key) async {
7479
final result = await cacheClient.delete(cacheName, key);
7580
switch (result) {
7681
case DeleteError():
@@ -88,8 +93,8 @@ Future<void> main() async {
8893
Duration(seconds: 30));
8994

9095
final cacheName = "doc-example-apis-${Uuid().v4()}";
91-
final key = StringValue("myKey");
92-
final value = StringValue("myValue");
96+
final key = "myKey";
97+
final value = "myValue";
9398

9499
await example_API_InstantiateCacheClient();
95100
await example_API_CreateCache(cacheClient, cacheName);

example/flutter_chat_app/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class _MyHomePageState extends State<MyHomePage> {
7777
}
7878

7979
Future<void> publishMessage() async {
80-
final result = await _topicClient.publish(
81-
"cache", "topic", StringValue(_textInputController.text));
80+
final result =
81+
await _topicClient.publish("cache", "topic", _textInputController.text);
8282
switch (result) {
8383
case TopicPublishSuccess():
8484
print("Successful publish");

example/quickstart/quickstart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Future<void> main() async {
77
Duration(seconds: 30));
88

99
final cacheName = "cache";
10-
final key = StringValue("key");
11-
final value = StringValue("value");
10+
final key = "key";
11+
final value = "value";
1212

1313
final setResp = await cacheClient.set(cacheName, key, value);
1414
switch (setResp) {

example/topics/advanced.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ void main() async {
1818
Timer(const Duration(seconds: 2), () async {
1919
// publish 10 messages spaced 1 second apart
2020
for (final i in Iterable.generate(10)) {
21-
var result =
22-
await topicClient.publish("cache", "topic", StringValue("hi $i"));
21+
var result = await topicClient.publish("cache", "topic", "hi $i");
2322
switch (result) {
2423
case TopicPublishSuccess():
2524
print("Successful publish!");

example/topics/basic_publisher.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ void main() async {
88

99
// publish 10 messages spaced 1 second apart
1010
for (final i in Iterable.generate(10)) {
11-
var result =
12-
await topicClient.publish("cache", "topic", StringValue("hi $i"));
11+
var result = await topicClient.publish("cache", "topic", "hi $i");
1312
switch (result) {
1413
case TopicPublishSuccess():
1514
print("Successful publish!");

0 commit comments

Comments
 (0)