class Caridina::Syncer
- Caridina::Syncer
- Reference
- Object
Overview
This object allow you to register listeners to be executed when some events are received.
This avoid you to have to parse the whole Responses::Sync
.
However #process_response
must be called with a Responses::Sync
manually.
This allow you to control precisely when you want to handle events.
syncer = Caridina::Syncer.new
syncer.on(Caridina::Events::Message) do |event|
# TODO: actually do something
end
syncer.process_response(sync)
Events sent to listeners are Events::Event
objects.
You should use a type restriction in order to access all their fields.
Defined in:
caridina/syncer.crInstance Method Summary
- #on(event_type : Events::Event.class, source = Source::All, &listener : EventListener) : Nil
- #on(event_type : Events::Event.class, source = Source::All, listener : EventListener | Nil = nil) : Nil
- #process_response(sync : Responses::Sync) : Nil
Instance Method Detail
def on(event_type : Events::Event.class, source = Source::All, listener : EventListener | Nil = nil) : Nil
#