Update annotations: scroll, static_grid, events, druid_instance

This commit is contained in:
Insality
2020-10-11 23:53:30 +03:00
parent 082aa454c6
commit 248b9c30f9
5 changed files with 181 additions and 158 deletions

View File

@@ -1,16 +1,16 @@
--- Lua event small library
-- @module druid_event
-- @module DruidEvent
-- @alias druid_event
local class = require("druid.system.middleclass")
-- @class DruidEvent
local Event = class("druid.event")
local DruidEvent = class("druid.event")
--- Event constructur
-- @function Event
-- @tparam DruidEvent self
-- @tparam function initial_callback Subscribe the callback on new event, if callback exist
function Event:initialize(initial_callback)
function DruidEvent.initialize(self, initial_callback)
self._callbacks = {}
if initial_callback then
@@ -20,9 +20,9 @@ end
--- Subscribe callback on event
-- @function event:subscribe
-- @tparam DruidEvent self
-- @tparam function callback Callback itself
function Event:subscribe(callback)
function DruidEvent.subscribe(self, callback)
assert(type(self) == "table", "You should subscribe to event with : syntax")
assert(type(callback) == "function", "Callback should be function")
@@ -33,9 +33,9 @@ end
--- Unsubscribe callback on event
-- @function event:unsubscribe
-- @tparam DruidEvent self
-- @tparam function callback Callback itself
function Event:unsubscribe(callback)
function DruidEvent.unsubscribe(self, callback)
for i = 1, #self._callbacks do
if self._callbacks[i] == callback then
table.remove(self._callbacks, i)
@@ -46,28 +46,28 @@ end
--- Return true, if event have at lease one handler
-- @function event:is_exist
-- @tparam DruidEvent self
-- @treturn bool True if event have handlers
function Event:is_exist()
function DruidEvent.is_exist(self)
return #self._callbacks > 0
end
--- Clear the all event handlers
-- @function event:clear
function Event:clear()
-- @tparam DruidEvent self
function DruidEvent.clear(self)
self._callbacks = {}
end
--- Trigger the event and call all subscribed callbacks
-- @function event:trigger
-- @param ... All event params
function Event:trigger(...)
-- @tparam DruidEvent self
-- @tparam any ... All event params
function DruidEvent.trigger(self, ...)
for i = 1, #self._callbacks do
self._callbacks[i](...)
end
end
return Event
return DruidEvent