Comments (6)
While reviewing some of the open PRs (and I forget which specifically) I also noticed that we, internally end up having to track this state with a boolean.
I agree that Amplify.isConfigured()
is a reasonable API to add to the library, in a first-class way.
@palpatim @manueliglesias, what do you think about adding this to iOS, JavaScript, Android?
from amplify-flutter.
I'm OK with this proposal. It would be nice to make Amplify.configure()
idempotent, but we didn't want to incorrectly give the impression that it was possible to override already-applied configurations. In iOS, we'd likely expose this as a property getter public static var isConfigured: Bool { get }
. Android would presumably expose public static Boolean isConfigured()
(or maybe boolean
? I'm not sure what our standard is).
from amplify-flutter.
Hi @ininmm thanks for bringing this to our attention.
Currently, you can have the following code to easily track if Amplify is configured:
await amplifyInstance.configure(amplifyconfig);
_amplifyConfigured = true;
What additional benefits do you think you'll have if you can access this as a field in your code?
from amplify-flutter.
@fjnoyp isConfigured()
is a good idea in that it stop you making every developer have to write the same code to store/check the state of the configuration. It is bad in that it makes isConfigured()
part of the API.
You could also take a different approach and be a little bit more permissive by only throwing the error if the config you are trying to use the second time is different from the original otherwise silently ignoring the repetition.
from amplify-flutter.
While I agree it's not difficult to track the state of Amplify independently, if Amplify has the requirement that it should not be re-configured it seems reasonable for Amplify to expose its state.
Regarding additional benefits, hot restart (not reload) seems like it would benefit from this change. Currently I have the configuration status stored in state that is reset on hot restart, but Amplify remains configured.
This PR seems to fix the configuration issue itself: #113
Where this is the original issue: #94
But I'm getting this error when my plugin code runs because my local state has been reset:
AmplifyException{message=The client tried to add a plugin after calling configure()., cause=null, recoverySuggestion=Plugins may not be added or removed after configure(...) is called.}
I'm only getting this on the DataStore plugin, not the Cognito plugin I initialized on the line before.
Maybe my code could be arranged differently to allow hot restart to work, maybe there could be a fix for the DataStore plugin and not Amplify itself. Either way it seems a lot of complexity could be avoided if Amplify exposed its state.
from amplify-flutter.
To be able to tell Amplify is already configured will be perfect! For now I've implemented this extension method as a temporary workaround:
import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_core_plugin_interface/amplify_core_plugin_interface.dart'; // <-- pulled this in
// The extension method
extension on Amplify {
bool hasConfiguredAuth() => AuthCategory.plugins.isNotEmpty;
}
// and using like so:
if (!amplifyInstance.hasConfiguredAuth()) {
amplifyInstance.addPlugin(
authPlugins: [auth],
analyticsPlugins: [analytics],
);
}
from amplify-flutter.
Related Issues (20)
- 'AuthProvider' doesn't conform to the bound 'Enum?' when setting up the Authenticator HOT 6
- Support for handling analytics in native code HOT 2
- when ever i am trying to do flutter run then a error occurs HOT 13
- PaginatedResult<T>.requestForNextResult does not use the authorizationMode from the previous query. HOT 6
- QUESTION: Is it possible to use an existing graphQL API not built with Amplify backend? HOT 2
- App Store Connect Warning: ITMS-91053: Missing API declaration HOT 5
- Flutter app crushes on Android release build HOT 7
- Update aws_common dependencies HOT 1
- How to set Public Read while uploading to files to aws. HOT 3
- Guidance on Integrating Flutter App Authentication with Next.js API using AWS Amplify HOT 4
- [amplify_auth_cognito] type 'FetchAuthSessionFetching' is not a subtype of type 'FetchAuthSessionSuccess' in type cast HOT 1
- Feature Request: Sharing authentication state between apps from the same developer HOT 6
- How to call Admin Queries API with authorization? HOT 1
- S3 access denied when making the API call. HOT 2
- No way to send unconfirmed user confirmation email when they restart the app HOT 5
- DataStore sync on Android physical devices takes very long time HOT 7
- Initial DataStore Sync Slow for Android Devices HOT 4
- fetchUserAttributes function cause toomanyrequestexception HOT 8
- AmplifyPushNotificationsPinpoint doesn't support offline configuration HOT 3
- Stuck in WebUI after authenticating with a certificate in iOS HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-flutter.