mirror of https://github.com/koreader/koreader
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
517 B
Lua
25 lines
517 B
Lua
11 years ago
|
--[[
|
||
|
The EventListener is an interface that handles events
|
||
|
|
||
|
EventListeners have a rudimentary event handler/dispatcher that
|
||
|
will call a method "onEventName" for an event with name
|
||
|
"EventName"
|
||
|
--]]
|
||
|
local EventListener = {}
|
||
|
|
||
|
function EventListener:new(o)
|
||
|
local o = o or {}
|
||
|
setmetatable(o, self)
|
||
|
self.__index = self
|
||
|
if o.init then o:init() end
|
||
|
return o
|
||
|
end
|
||
|
|
||
|
function EventListener:handleEvent(event)
|
||
|
if self[event.handler] then
|
||
|
return self[event.handler](self, unpack(event.args))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return EventListener
|