abstract class Pulsar::TimedEvent

Defined in:

pulsar/timed_event.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.subscribe(&block : self, Time::Span -> Nil) #

Subscribe to events

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

MyEvent.new.publish do
  # Do something
end

[View source]

Instance Method Detail

def name #

Returns the name of the event.

The event name is the name of the class. So an class of MyShard::MyEvent would return "MyShard::MyEvent".


[View source]
def publish(&) : Time::Span #

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.new.publish do
  # Run some code
end

The #publish method also returns the duration it took to run the block.


[View source]
def started_at #

When the event started


[View source]