-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hotswap discards non-table values #18
Comments
The problem here is that there's no way to modify existing functions: if you've required and stored the same function somewhere else in the past, that version doesn't get updated with your patch, which means hotswap doesn't actually hotswap anything in that case. A workaround could be to use __call like so: local function drop_args(n, f) return function(...) return f(select(n, ...)) end end
return setmetatable({}, {__call = drop_args(1, my_function)}) This is a normal, modifiable table object, so it should work with hotswap, but you can call it as if it were a normal function. That said, if the current behavior is fine with you you can do the same thing manually, without modifying hotswap: package.loaded[my_mod] = nil
local f = require(my_mod) |
right, afaik you can only emulate updating existing references either by utilizing a wrapper table or by replacing all of an existing table's values. that's why, in my example code, i'm running what i'm really trying to describe is that i figured hotswap would update non-table return values in nulling out the key in |
https://github.com/rxi/lume/blob/da0d1bb/lume.lua#L694-L695
currently, if the returned value of a module isn't a table, it (newmod) is discarded.
in my case, my module returns a function, and i expect
package.loaded
to contain the new value. i am usinglurker.lua
to trigger hotswapping.this dirty hack seems to work:
The text was updated successfully, but these errors were encountered: