core
core copied to clipboard
WIP - Implement app.shutdown() function.
Closes #886.
Thanks for suggesting these code changes. To set expectations:
- Pull requests are reviewed in batches, so it can take some time to get a response.
- Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why here.
- Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.
Finally, please be patient with the core team. They are trying their best with limited resources.
@janwirth great to have some contribution in this direction. Two questions:
- How would subscriptions be unbound and event handlers removed? (I see you still have a WIP in the title so maybe my comment is a bit early)
- I noticed you used
const, but the rest of the Elm kernel code usesvar.
- I am relying on the implementation shared by @supermario, I'm not the author so perhaps he can offer an explanation
- fixed.
The gist I shared on unmounting covers port unsubscribes, which are manual in that context.
If this shutdown() is intended to be holistic, it should probably be extended to do the port unsubscribes automatically as well. I could look into this in a few weeks from now if nobody does so till then.
There's a tangential issue here of unsubscribeAll() also being missing, i.e. without manually retaining references to all the subscribed handlers, I believe there's no way to clear out all subscribed handlers at once. Though I can't think of any use-cases for that now where one would want to do that but not shutdown().