StimulusReflex server callbacks PR that I made where you can see a more advanced example on what you can do with this Callbacks module:
https://github.com/hopsoft/stimulus_reflex/pull/160

Some of the code used in this video:

module Benchmarkable
  extend ActiveSupport::Concern

  included do
    include ActiveSupport::Callbacks

    define_callbacks :benchmark
    # you can set before, around or after
    set_callback :benchmark, :around, :around_benchmark
  end

  def around_benchmark
    time_before = Time.now
    yield
    time_after = Time.now

    puts "TOTAL TIME: #{time_after - time_before} seconds"
  end
end

class Person
  include Benchmarkable

  def do_something
    run_callbacks :benchmark do
      puts "DO SOMETHING"
      sleep 3
    end
  end
end

p = Person.new
p.do_something