Replies: 4 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 ;) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Is there a reason for |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@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
Beta Was this translation helpful? Give feedback.
All reactions