Add cleanup function

This commit is contained in:
Rahix 2017-04-16 00:24:52 +02:00 committed by Rahix
parent 08ca559ade
commit 4dd809ba03

7
bc.lua
View file

@ -138,6 +138,8 @@ function bc:init(my_address, local_nouns, local_verbs)
end
-- Change this for deployment VVV
o.modem = modem:init(my_address, modem_listener)
-- Save listener function for deinit
o.modem_cb = modem_listener
-- Init local stuff
o.local_verbs = local_verbs or {}
o.local_nouns = local_nouns or {}
@ -268,4 +270,9 @@ function bc:listen_cancel(n, id)
end
end
-- Deinit
function bc:cleanup()
event.ignore("modem_message", self.modem_cb)
end
return bc