aboutsummaryrefslogtreecommitdiff
path: root/lua/api.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/api.lua')
-rw-r--r--lua/api.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/lua/api.lua b/lua/api.lua
new file mode 100644
index 0000000..d078d72
--- /dev/null
+++ b/lua/api.lua
@@ -0,0 +1,13 @@
+local function shallow_copy(t)
+ local t2 = {}
+ for k, v in pairs(t) do t2[k] = v end
+ return t2
+end
+
+web.event.add_listener = function(events, opts)
+ opts = shallow_copy(opts or {})
+ if type(events) ~= "table" then events = { events } end
+ opts.events = events
+
+ __internals.register_event(opts)
+end