-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Make pushing a new scope atomic. #364
Comments
sounds like an absolute reasonable request. will implement in the next release |
Thank you. |
done in upcoming V8 |
I added a comment to the commit here: afa6dd3#r147433011 But adding here as well for easier tracking: If there is an error thrown during scope push, the |
I didn't know that is is possible to add a comment to any commit. Interesting. |
That is a great question and I am not sure that there is an easy answer. |
Where would you call the |
Yes, I noticed this in a failing test case, so this is a use case. |
If we see the pushing of a new scope as something that consists of creating the new scope but also the successful finish of the init function, the correct behavior is probably to remove the scope and throw an error |
After thinking about this for a couple minutes, I think this is the best approach. Removing the scope and all its registrations. If it is left as is, it is not predictable at all. |
does this look good? _pushScopeInProgress = true;
_scopes.add(_Scope(name: scopeName, disposeFunc: dispose));
try {
init?.call(this);
if (isFinal) {
_scopes.last.isFinal = true;
}
onScopeChanged?.call(true);
} catch (e) {
final failedScope = _scopes.last;
/// prevend any new registrations in this scope
failedScope.isFinal = true;
failedScope.reset(dispose: true);
_scopes.removeLast();
rethrow;
}
finally {
_pushScopeInProgress = false;
} |
I think so! |
If you want, I can create a PR and add a test |
let me push my change and please, add a test, that would be awesome |
pushed |
@escamoteur I create a PR with the tests and also 2 other PRs with small improvements. |
@escamoteur Is there anything missing to get my PRs merged and this fix possibly released? |
Oh, sorry, no I was just too busy. Let me check later today.
Am 21. Okt. 2024, 16:07 +0100 schrieb Peter Leibiger ***@***.***>:
… @escamoteur Is there anything missing to get my PRs merged and this fix possibly released?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
merged and published V8.0.1 thanks a lot |
Thanks! |
Really appreciated your contribution.
If you want to help maintaining get_it you are more than welcome 😁
Am 22. Okt. 2024, 09:47 +0100 schrieb Peter Leibiger ***@***.***>:
… Thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
When
pushNewScope
is called with theinit
function provided, throw an exception if there is an attempt to push another scope during the execution ofinit
. This is useful when delegating to individual sub-modules the registration of objects to a scope defined/controlled by the parent.Thank you.
The text was updated successfully, but these errors were encountered: