HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
439 stars 77 forks source link

Add a quit event/handler #37

Closed fluffynukeit closed 11 years ago

fluffynukeit commented 11 years ago

TPG should offer users a way to register actions to be triggered when a user disconnects, navigates away from the page, closes the window, etc. Among other things, this would allow easy freeing of resources that were allocated for the user's session.

HeinrichApfelmus commented 11 years ago

I have implemented this event while fixing the WebSocket implementation. The Chat example demonstrates how it can be used.

Does that work for you?

HeinrichApfelmus commented 11 years ago

Bump. I intend to release version 0.3 on hackage once you can give me your ok here.

fluffynukeit commented 11 years ago

I have not migrated to a new TPG version in quite a while (I was hard at work planning my recent wedding). Now that I'm getting ready to release the first version of my app, I don't think I'll be doing any new migration anytime soon. If you feel confident about the new functionality, go ahead and release it. I unfortunately won't be able to give feedback (if any) on it for quite some time.

HeinrichApfelmus commented 11 years ago

Ok, no problem. In that case, I will close the remaining issues that have been fixed for milestone 0.3. Feel free to reopen them or open new ones as usual.

Thanks again for your feedback and contributions so far, it really helped shape the library! (And congratulations on your marriage! :smile:)

Porges commented 7 years ago

A random but associated question: how can I cleanly make the server quit? I resorted to attempting to exitWith but that only results in a console message and the server continues to run (I assume the server is catching and handling exceptions on the threads).

HeinrichApfelmus commented 7 years ago

@Porges Please feel free to open a new issue, to keep topics separate.

To answer your question, Threepenny runs everything in separate threads, and the documentation for exitWith indicates that exiting a thread may not quite the whole program — which makes sense, since there might be other browser windows connected to the server. See also the blog post "Exiting a Haskell process".