Add cleanup function

dev
Rahix 9 years ago committed by Rahix
parent 08ca559ade
commit 4dd809ba03

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

Loading…
Cancel
Save