saskodh / framework

Lightweight web framework for NodeJS inspired by Spring framework
26 stars 5 forks source link

Add support for @Component life-cycle hooks #14

Closed damjangelovski closed 8 years ago

damjangelovski commented 8 years ago

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:

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 commented 8 years ago

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