Open dgagnon opened 1 year ago
There does not seem to be an easy way to know which exceptions can be returned by datastore or the hub. Let me know if I should open another issue.
Hey @dgagnon
Thank you for the detailed write up!
I agree this would be a significant improvement.
I have opened #3454 to address this gap.
Re: OutboxMutationFailed
missing on Swift, I will follow up with the Swift team and provide an update when I have it.
Opened a feature request on amplify-swift for the missing type.
Further discussion for amplify-swift will be tracked there.
Thanks again for bringing this to our attention!
I see this was fixed in 1.3.0, great work!
With the new enum in place, would probably be a good idea to update the doc as well; https://docs.amplify.aws/lib/datastore/datastore-events/q/platform/flutter/#usage
Do you guys take external PRs ?
If not:
try {
hubDatastoreSubscription = Amplify.Hub.listen(HubChannel.DataStore, (hubEvent) {
switch (hubEvent.type) {
case DataStoreHubEventType.ready:
safePrint('Datastore is ready.');
case DataStoreHubEventType.outboxMutationFailed:
// BUG: Android only: https://github.com/aws-amplify/amplify-swift/issues/3102
safePrint('Datastore outboxMutationFailed.');
case DataStoreHubEventType.networkStatus:
safePrint('Datastore networkStatus event.');
case DataStoreHubEventType.outboxStatus:
safePrint('Datastore outboxStatus event.');
case DataStoreHubEventType.subscriptionsEstablished:
safePrint('Datastore subscriptionsEstablished.');
case DataStoreHubEventType.syncQueriesStarted:
safePrint('Datastore syncQueriesStarted.');
case DataStoreHubEventType.modelSynced:
safePrint('Datastore modelSynced.');
case DataStoreHubEventType.syncQueriesReady:
safePrint('Datastore syncQueriesReady.');
case DataStoreHubEventType.subscriptionDataProcessed:
safePrint('Datastore subscriptionDataProcessed.');
case DataStoreHubEventType.outboxMutationEnqueued:
safePrint('Datastore outboxMutationEnqueued.');
case DataStoreHubEventType.outboxMutationProcessed:
safePrint('Datastore outboxMutationProcessed.');
}
});
} catch (e) {
safePrint('Could not setup the Datastore subscription: $e');
}
@dgagnon Absolutely, external PRs are always appreciated! 🙏
Description
When building switch cases to handle all possible DataStoreHubEvent, many of the underlying events do not have corresponding DataStoreHubEvent classes:
see amplify_datastore-1.2.0-supports-only-mobile+1\lib\src\amplify_datastore_stream_controller.dart:
This forces developper to instead check for the eventName string. This not ideal for 2 reasons:
Also, Amplify-Android has an event called OutboxMutationFailed, which is very useful is it allows reacting right away when an error occurs. I see that swift does not seem to have an equivalent. I would be great to have this in amplify-flutter.
See https://docs.amplify.aws/lib/datastore/datastore-events/q/platform/android/#outboxmutationfailed
Categories
Steps to Reproduce
Screenshots
Platforms
Flutter Version
3.10.5
Amplify Flutter Version
1.2.0-supports-only-mobile+1
Deployment Method
Amplify CLI
Schema