New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add application lifecycle events #9513

Open
cboulanger opened this Issue Mar 26, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@cboulanger
Contributor

cboulanger commented Mar 26, 2018

For libraries and other type of code that does not have control over the main application, or which is designed to be only loosely coupled, it is useful to be able to observe the state of the application lifecycle.

The main application instance should therefore fire (at least) the following events:

  • beforeMain
  • afterMain
  • beforeFinalize
  • afterFinalize
  • beforeTerminate

afterMain and beforeFinalize are probably identical.

@cboulanger cboulanger self-assigned this Mar 26, 2018

@level420

This comment has been minimized.

Member

level420 commented Mar 27, 2018

The question is at which point the event handlers get called. Does the event queue run between beforeMain and afterMain? Or are they both handled within the same event queue run which would mean that we have for both events the application in the "after main" state when running the event handlers? Or do we need some synchronous mechanism here (e.g. "callbacks")?

But in general I think this would be a good addition.

@cboulanger

This comment has been minimized.

Contributor

cboulanger commented Mar 27, 2018

If we want to be on the safe side, we fire a beforeX and afterX event for each of the interface methods of qx.application.IApplication.

The firing of the events should probably go into qx.core.BaseInit, but I'll have to do some research first.

@cboulanger cboulanger closed this Mar 27, 2018

@cboulanger cboulanger reopened this Mar 27, 2018

@cboulanger

This comment has been minimized.

Contributor

cboulanger commented Mar 27, 2018

Sorry wrong button, reopened....

@level420

This comment has been minimized.

Member

level420 commented Mar 27, 2018

Still I think it is worth to think about the fact that all fired events will be handled in one queue run. So I think that the execution sequence will be:

  • fire beforeMain event
  • call main
  • fire afterMain event
  • fire beforeFinalize event
  • call finalize --> calls qx.ui.core.queue.Manager.flush() leads to the event queue being processed
  • call beforeMain event handler
  • call afterMain event handler
  • call beforeFinalize event handler
  • fire afterFinalize event handler
  • ... some queue flush later ...
  • call afterFinalize event handler
@cajus

This comment has been minimized.

Contributor

cajus commented Mar 27, 2018

qx.bom.Lifecycle already does some of them.

@cboulanger

This comment has been minimized.

Contributor

cboulanger commented Mar 27, 2018

Important points, thanks! Will have a look at the queue manager and qx.bom.Lifecycle. Will take me until after Easter though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment