owickstrom / gi-gtk-declarative

Declarative GTK+ programming in Haskell
https://owickstrom.github.io/gi-gtk-declarative/
288 stars 35 forks source link

Make run return the last state of the application after exiting #20

Closed ludat closed 5 years ago

ludat commented 5 years ago

Fixes #9.

owickstrom commented 5 years ago

Regarding the CI fail, let me see if I can fix the build script tomorrow morning.

owickstrom commented 5 years ago

That sounds better. Rather use async than the MVar primitives. Go for it! :)

Den ons 5 dec. 2018 03:50Lucas David Traverso notifications@github.com skrev:

@ludat commented on this pull request.

In gi-gtk-declarative-app-simple/src/GI/Gtk/Declarative/App/Simple.hs https://github.com/owickstrom/gi-gtk-declarative/pull/20#discussion_r238916003 :

Gtk.main

  • wait lastState

You are totally right, someone could call Gtk.mainQuit from anywhere and it should stop Gtk.main.

I think that a better approach could be checking if the async finished or not using some async function, after some digging async provides poll :: Async a -> IO (Maybe (Either e a)) where Nothing means the thread hasn't finished, Just Right means it finished successfully and Just Left means an exception was thrown, I think I can use that and forward the Nothing and Just Right cases and throw an exception in the Just Left case, does that sound like a good idea? I don't think introducing more state is necessary to solve this particular issue.

Also that would give me the change to kill the thread if it outlived Gtk.main which sounds like a good idea, if the user feels like calling Gtk.mainQuit for some reason.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/owickstrom/gi-gtk-declarative/pull/20#discussion_r238916003, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZYCI7YsWV5sb2U00tIokleqGAVRryvks5u1zRegaJpZM4Y95FP .

-- Mvh, Oskar Wickström

owickstrom commented 5 years ago

The master branch is now green, so if you rebase or merge that in, your PR should pass CI.

owickstrom commented 5 years ago

Thank you for the PR!