-
Notifications
You must be signed in to change notification settings - Fork 2.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Question : DocumentStore implementation #12918
Comments
Yes it is used internally by the document manager, e.g. to update the shared cache if the session was committed successfully, but only once even if the But yes, we could have allowed to pass distinct but multiple delegates for a given document type. Hmm, look at Open to any suggestion ;) |
OK, it seems quite complicated to retain if a handler is already registered at the service level as service (i.e. DocumentManager) can be singleton and DocumentStore is scoped. There can be failure or cancel... But things can be quite simpler like this : public void AfterCommitSuccess<T>(DocumentStoreCommitSuccessDelegate afterCommitSuccess)
{
if (!_afterCommitSuccess?.GetInvocationList().Contains(afterCommitSuccess) ?? true)
{
_afterCommitSuccess += afterCommitSuccess;
}
}
/// <inheritdoc />
public void AfterCommitFailure<T>(DocumentStoreCommitFailureDelegate afterCommitFailure)
{
if (!_afterCommitFailure?.GetInvocationList().Contains(afterCommitFailure) ?? true)
{
_afterCommitFailure += afterCommitFailure;
}
} It removes the need of I can make a PR if you think it's correct. |
Is there a reason for |
This is what we first used in Yes, at first
To allow multiple delegates to be registered but still one per document type. Maybe not needed if we check |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
@jtkech Is there a reason to prevent registering multiple
AfterCommitSuccess
/AfterCommitFailure
handlers on the same document type ?Probably to prevent registering the same handler multiple times, but isn't this the service responsibility to do that ?
It could lead to unattended behavior if different services try to register an handler on the same document type.
OrchardCore/src/OrchardCore/OrchardCore.Data.YesSql/Documents/DocumentStore.cs
Lines 112 to 129 in 231cb19
The text was updated successfully, but these errors were encountered: