Skip to content
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 support for @Component life-cycle hooks #14

Closed
damjangelovski opened this issue Jul 12, 2016 · 1 comment · Fixed by #24
Closed

Add support for @Component life-cycle hooks #14

damjangelovski opened this issue Jul 12, 2016 · 1 comment · Fixed by #24
Assignees

Comments

@damjangelovski
Copy link
Collaborator

damjangelovski commented Jul 12, 2016

Background

The components lifetime is fully managed by the DI container(injector).
The components should be able to react to some of it's life-cycle events like post constructing and pre destroying.

Task

Add support for component's life-cycle hooks. Those would be methods decorated with the appropriate decorator for one of the life-cycle events like:

  • @PostConstruct - after the component is initialized and it's dependencies are set
  • @PreDestroy - before the component is destroyed

Note: Before implementing @PreDestroy support for destroying the AppContext manually and through some of the process events for exit needs to be added. Example:

let ctx = new ApplicationContext();

// Manually
ctx.destroy();

// On exit
ctx.registerExitHook();
@saskodh saskodh changed the title Add support for class token and alias tokens on components Add support for @Component life-cycle hooks Jul 14, 2016
damjangelovski added a commit that referenced this issue Jul 15, 2016
- added @PostConstruct and @PreDestroy
- added destroy() and registerExitHook() in ApplicationContext
saskodh added a commit that referenced this issue Jul 17, 2016
- added support for async @PostConstruct and @PreDestroy methods
- ApplicationContext is initialized with the async start method instead of on construction time
- made the ApplicationContext state aware
@saskodh
Copy link
Owner

saskodh commented Jul 17, 2016

Reopened: exit hook does not trigger when the process is killed (Ctrl + C).

damjangelovski added a commit that referenced this issue Jul 18, 2016
- added ProcessHandler with observer pattern
- added exiting on SIGINT hook
saskodh added a commit that referenced this issue Jul 18, 2016
- added minor changes and improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants