Skip to content
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

Callback for when a plugin is reloaded #2

Open
AndreLouisIssa opened this issue May 23, 2024 · 1 comment
Open

Callback for when a plugin is reloaded #2

AndreLouisIssa opened this issue May 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@AndreLouisIssa
Copy link
Member

AndreLouisIssa commented May 23, 2024

proposed on_reload (unsure where it would be put, perhaps a new namespace called meta?)

would make it easier for plugins that manage other plugins to clear any information would otherwise accumulate negatively over reloads.

e.g.

rom.<namespace>.on_reload(function(env)
    my_callbacks[env._PLUGIN.guid] = {}
end)

or

rom.<namespace>.on_reload(function(env)
    local callbacks = my_callbacks[env._PLUGIN.guid]
    if callbacks == nil then return end
    for k in pairs(callbacks) do
        callbacks[k] = nil
    end
end)

or it could be used to declare some features inert in preparation for a reload as they might not make sense in that context (e.g. managing external state like sockets, file handles etc.).

unsure if there's any benefit in an on_reload.post variant, I suppose it could be used for removing any flags that might have been set in on_reload.pre.

@AndreLouisIssa
Copy link
Member Author

AndreLouisIssa commented May 23, 2024

alternatively: on_load which functions exactly the same except it's every subsequent load of a plugin, except there's another argument to the callback, reloaded boolean that is true only if it's a reload, and false if it's an initial load.

I can only think of this variant being useful if it was specifically on_load.post, used by a plugin on itself or by another plugin on a calling plugin to basically fulfil ReLoad's job to split the initial load and reload codepaths, but in a rather limited way.

But if part of our goals is to eliminate the need for a lot of my modules by bringing them into the base loader, this could be such a way.

@AndreLouisIssa AndreLouisIssa added the enhancement New feature or request label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant