| Module | RubyTorrent::EventSource |
| In: |
lib/rubytorrent/util.rb
|
"events": very similar to Observable, but cleaner, IMO. events are listened to and sent in instance space, but registered in class space. example:
class C
include EventSource
event :goat, :boat
def send_events
send_event :goat
send_event(:boat, 3)
end
end
c = C.new c.on_event(:goat) { puts "got goat!" } c.on_event(:boat) { |x| puts "got boat: #{x}" }
Defining them in class space is not really necessary, except as an error-checking mechanism.