support unregistering a service
weissi opened this issue · 2 comments
weissi commented
In certain cases it could be useful to register
and then unregister
a service, maybe because that service has been shut down independently for some reason.
Today, this is possible but just forgetting about a registered service (and making the shutdown function do nothing). Unfortunately, that would cause the registration to consume memory forever...
I'd like to see an API like this:
// the return value is usually ignore (`@discardableResult`)
let registrationToken = lifecycle.register(...)
...
lifecycle.unregister(registrationToken, runShutdown: false)
weissi commented
CC @Davidde94