abstract class Pulsar::TimedEvent
- Pulsar::TimedEvent
 - Reference
 - Object
 
Defined in:
pulsar/timed_event.crClass Method Summary
- 
        .subscribe(&block : self, Time::Span -> Nil)
        
          
Subscribe to events
 
Instance Method Summary
- 
        #name
        
          
Returns the name of the event.
 - 
        #publish(&)
        
          
Publishes the event when the block finishes running.
 - 
        #started_at
        
          
When the event started
 
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
        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".
        
        def publish(&)
        #
      
      
        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 returns the result of the block.