Pokedex5E icon indicating copy to clipboard operation
Pokedex5E copied to clipboard

Profile loading enhancement: make event-based

Open magroader opened this issue 5 years ago • 0 comments

From discord convo:

The only thing that should call load() on something that needs a profile IS the profile code. It should do so via a callback mechanism, and the profile should be passed in so like, for storage:

local function load_profile(profile)
  -- grab stuff from the profile
end

function M.init()
  ...
  profiles.register_load_cb(load_profile)
end

and the profile code should call all those callbacks when it's in the process of changing profiles then all the load() calls all over the gui_script and main code should be burned to the ground

i love doing things with event callbacks because it allows you to have your dependencies go in a logical way storage is based on profiles, so storage depends on profiles... there's not some backward thing where profile gui_script needs to know about storage, i mean why would it?

magroader avatar Jul 25 '20 18:07 magroader