Skip to content

Module loader/builder & Graceful shutdown for Providers & Lifecycles #30

@znotfireman

Description

@znotfireman
local root = prvd.start()
-- later, shutdown is also binded to game.Close
root.shutdown()

---

local event = Lifecycle("onEvent", prvd.fireConcurrent)
function event:shutdown()
  -- cleanup
end

---

local provider = {}

function provider:onShutdown()
  -- cleanup
end

Some notes from the Discord thread:

what if a custom lifecycle has events?
DarkModule: how would I clean it up?
store the event somewhere and either hook onto onShutdown and clean it up (via the lifecycles package) or listen to game.BindToClose / game.Close
i havent figured out a good way to do this yet
i might follow what flamework did and have prvd.start return an object to extinguish stuff
and give lifecycles a way to be cleaned up
can I put a lifecycle inside a provider?
absolutely
but dont put it inside a lifecycle method
but wouldn't that cause lifecycle to be called after onstart?
because the execution model shows lifecycles to be called before onstart no?
ahh hah but howwould I clean up the connection from SomeService.Event?
ok for example lets say I want a onPlayerDeath lifecycle
humanoid changes everytime a character is added
just an example, I want to clean up other connections that are related to humanoid from before
how would I do that?
there isnt a great way yet sadly
uhh
what the lifecycles package does is
store the connections smwhere
and disconnect them onshutdown
ok going back to an older topic, you should have a lifecycle (for example :lifecycleInitialize) as apart of all providers that runs before prvd.Lifecycle() which can include custom life cycles inside providers. But this can become hectic and pretty bloated
a lifecycle provider can just specify loadOrder = 0
and it will load before every other provider
the default is 1
I know this is so we can provide a clean up to events
yeah
in an ideal world onShutdownw ould be moved away from the lifecycles package
ctually offtopic but onStart is distinctly different from real lifecycles
only reason why onStart is constructed inside startup is bcuz of startup options
ok the event:shutdown() method shhould fiix my original problem
it doesnt exist yet
at all
but i should keep it in mind
yep
ok great

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature for a Prvd 'M Wrong packagehelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions