-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Update get_it_impl.dart to dispose in reverse order #350
Conversation
Hey, after reading the docs of the linked hash map it seems that that would solve the problem without hurting performance.
Good idea
Cheers
Thomas
Am 22. Nov. 2023, 10:00 +0100 schrieb Kevin De Keyser ***@***.***>:
… @bvoq commented on this pull request.
In lib/get_it_impl.dart:
> @@ -309,7 +309,7 @@ class _Scope {
Future<void> reset({required bool dispose}) async {
if (dispose) {
- for (final factory in allFactories) {
+ for (final factory in allFactories.reversed) {
Perhaps an easier way would be to use LinkedHashMap instead, which is order-preserving by default.
Would you be interested in such a PR?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Alright I've added tests, one of which fails with the current version but not with this new version. Minor note: I wouldn't rename the type of
which is not of subtype: // ignore: prefer_collection_literals
final factoriesByName = LinkedHashMap<String?,LinkedHashMap<Type, _ServiceFactory<Object, dynamic, dynamic>>>(); Without renaming the type, this could be released as a minor update. I'm ok with it either way, do you want to edit the Thanks for looking at the PR! |
Why do you think a change of the type of this this internal data structure might break any apps that use get_it? Change log addition would be fine. Also do we already have a note in the docs pointing out that we now dispose in reverse order? |
… in the reverse order in which they were registered
I was wrong, my bad. I didn't see that it was part of a private class _Scope. |
thanks a lot for this fine PR, I just published a new version |
There are a few situations, where one instance depends on an instance you created before.
In all of these situations, it makes more sense to dispose of the widgets in reverse order.