class

Pulsar::TimedEvent

Inherits Pulsar::BaseEvent < Reference < Object

Class methods

publish(*args_, **named_args_, &)

Publishes the event when the block finishes running.

Similar to Pulsar::Event#publish but measures and publishes the time it takes to run the block.

MyEvent.publish do
  # Run some code
end

The publish method returns the result of the block.

Passing arguments to initialize

If your event defines an initialize and requires arguments, you can pass those arguments to publish.

For example if you had the event:

class MyEvent < Pulsar::TimedEvent
  def initialize(custom_argument : String)
  end
end

You would pass the arguments to publish and they will be used to initialize the event:

MyEvent.publish(custom_argument: "This is my custom event argument") do
  # ...run some code
end
Source
subscribe

Subscribe to events

MyEvent.subscribe do |event, duration|
  # Do something with the event and duration
end

MyEvent.publish do
  # Do something
end
Source

Instance methods

started_at

When the event started