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

fix: use type-specific methods in public clients, Value in internal clients #90

Merged
merged 10 commits into from
Jan 12, 2024
19 changes: 12 additions & 7 deletions example/doc_example_apis/doc_example_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Future<void> example_API_InstantiateCacheClient() async {
}
}

Future<void> example_API_CreateCache(CacheClient cacheClient, String cacheName) async {
Future<void> example_API_CreateCache(
CacheClient cacheClient, String cacheName) async {
final result = await cacheClient.createCache(cacheName);
switch (result) {
case CreateCacheAlreadyExists():
Expand All @@ -36,7 +37,8 @@ Future<void> example_API_ListCaches(CacheClient cacheClient) async {
}
}

Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName) async {
Future<void> example_API_DeleteCache(
CacheClient cacheClient, String cacheName) async {
final result = await cacheClient.deleteCache(cacheName);
switch (result) {
case DeleteCacheError():
Expand All @@ -47,7 +49,8 @@ Future<void> example_API_DeleteCache(CacheClient cacheClient, String cacheName)
}
}

Future<void> example_API_Set(CacheClient cacheClient, String cacheName, Value key, Value value) async {
Future<void> example_API_Set(
CacheClient cacheClient, String cacheName, String key, String value) async {
final result = await cacheClient.set(cacheName, key, value);
switch (result) {
case SetError():
Expand All @@ -58,7 +61,8 @@ Future<void> example_API_Set(CacheClient cacheClient, String cacheName, Value ke
}
}

Future<void> example_API_Get(CacheClient cacheClient, String cacheName, Value key) async {
Future<void> example_API_Get(
CacheClient cacheClient, String cacheName, String key) async {
final result = await cacheClient.get(cacheName, key);
switch (result) {
case GetMiss():
Expand All @@ -70,7 +74,8 @@ Future<void> example_API_Get(CacheClient cacheClient, String cacheName, Value ke
}
}

Future<void> example_API_Delete(CacheClient cacheClient, String cacheName, Value key) async {
Future<void> example_API_Delete(
CacheClient cacheClient, String cacheName, String key) async {
final result = await cacheClient.delete(cacheName, key);
switch (result) {
case DeleteError():
Expand All @@ -88,8 +93,8 @@ Future<void> main() async {
Duration(seconds: 30));

final cacheName = "doc-example-apis-${Uuid().v4()}";
final key = StringValue("myKey");
final value = StringValue("myValue");
final key = "myKey";
final value = "myValue";

await example_API_InstantiateCacheClient();
await example_API_CreateCache(cacheClient, cacheName);
Expand Down
4 changes: 2 additions & 2 deletions example/flutter_chat_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> publishMessage() async {
final result = await _topicClient.publish(
"cache", "topic", StringValue(_textInputController.text));
final result =
await _topicClient.publish("cache", "topic", _textInputController.text);
switch (result) {
case TopicPublishSuccess():
print("Successful publish");
Expand Down
4 changes: 2 additions & 2 deletions example/quickstart/quickstart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Future<void> main() async {
Duration(seconds: 30));

final cacheName = "cache";
final key = StringValue("key");
final value = StringValue("value");
final key = "key";
final value = "value";

final setResp = await cacheClient.set(cacheName, key, value);
switch (setResp) {
Expand Down
3 changes: 1 addition & 2 deletions example/topics/advanced.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void main() async {
Timer(const Duration(seconds: 2), () async {
// publish 10 messages spaced 1 second apart
for (final i in Iterable.generate(10)) {
var result =
await topicClient.publish("cache", "topic", StringValue("hi $i"));
var result = await topicClient.publish("cache", "topic", "hi $i");
switch (result) {
case TopicPublishSuccess():
print("Successful publish!");
Expand Down
3 changes: 1 addition & 2 deletions example/topics/basic_publisher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ void main() async {

// publish 10 messages spaced 1 second apart
for (final i in Iterable.generate(10)) {
var result =
await topicClient.publish("cache", "topic", StringValue("hi $i"));
var result = await topicClient.publish("cache", "topic", "hi $i");
switch (result) {
case TopicPublishSuccess():
print("Successful publish!");
Expand Down
Loading