after all transaction commit only then do something

Edit
equivalent Web Development
Public
Rails
ActiveRecord
e.g after all transactions to DB saved the send emails, or index a document in ElastcSearch

def save!
  raise ActiveRecord::RecordInvalid, self unless valid?

  ActiveRecord::Base.transaction do
    update_or_create_client!
    # ....
  end

  ActiveRecord.after_all_transactions_commit do
    send_emails
  end
end