Hi all,
I’m curious about how to “unrequire” an external module that is built in the awesome localized method suggested by Jon Beebe a few months ago (detailed here: http://blog.anscamobile.com/2011/09/a-better-approach-to-external-modules/).
For example, the module is set up like so:
--file: testmodule.lua
-- define a local table to store all references to functions/variables
local M = {}
local testFunction1 = function()
end
-- return the table to be used locally elsewhere
return M
I’d like to both require this module and UN-require it when needed, to free up memory when none of the functions within it are needed. Is doing so as simple as this?
--file: main.lua
local testmod --local upvalue reference variable
--to require it:
testmod = require("testmodule")
--to UN-require it:
testmod = nil
Basically I’m looking for a foolproof way to both require and un-require external modules as needed within my main.lua
code body. Has anybody used this approach, or another similar approach entirely?
Thanks!
Brent Sorrentino
Ignis Design [import]uid: 9747 topic_id: 20240 reply_id: 320240[/import]