There are predefined events like EntityCreatedEventData
that are published after the transaction is successfully committed.
I would like to publish a custom Event
after the transaction is successfully committed. Is that possible with the current API?
Yes, that is possible with the current API.
From https://docs.abp.io/en/abp/latest/Unit-Of-Work#other-iunitofwork-properties-methods:
OnCompleted
method gets a callback action which is called when the unit of work successfully completed (where you can be sure that all changes are saved).
var uow = _unitOfWorkManager.Current;
uow.OnCompleted(() =>
{
await _eventBus.PublishAsync(new MyCustomEvent());
});
This is the same API that is used for EntityCreatedEventData
.