lifecycle-hook

Invoke a script on EC2 termination

妖精的绣舞 提交于 2020-06-26 06:39:28
问题 I have to take certain actions during AWS autoscaling scale-in event.The ec2 instance should be able to save some logs and reports to S3 bucket. This can take anywhere between 5 to 15 mins. I already have a script that gets called on termination: ln -s /etc/ec2-termination /etc/rc0.d/S01ec2-termination However the script ends abruptly within 5 mins. I am looking at leveraging AWS LifeCycle hooks to extend the EC2 lifetime. The documentation is not clear on invoking a script in a way similar

How do I run a function on ngOnInit() only once and not again upon returning back from another routerLink?

折月煮酒 提交于 2019-12-06 14:40:25
问题 HomeComponent ngOnInit() { console.log('loaded'); this.retrieveData(); } retrieveData() { // this.dataService.getData().subscribe(...); } I am retrieving data when the component loads. When the user clicks on another routerLink , for example, SettingsComponent and returns back to the HomeComponent , the function of course, is called again because the component has loaded again. But Everytime I return back to the component, it makes the function call again which creates too many unwanted HTTP

How do I run a function on ngOnInit() only once and not again upon returning back from another routerLink?

五迷三道 提交于 2019-12-04 20:13:26
HomeComponent ngOnInit() { console.log('loaded'); this.retrieveData(); } retrieveData() { // this.dataService.getData().subscribe(...); } I am retrieving data when the component loads. When the user clicks on another routerLink , for example, SettingsComponent and returns back to the HomeComponent , the function of course, is called again because the component has loaded again. But Everytime I return back to the component, it makes the function call again which creates too many unwanted HTTP requests. I need to prevent this and make sure the function is called only the first time. How do I do

{{ call() }} in template executes the method block multiple times?

雨燕双飞 提交于 2019-11-29 15:03:35
Here the statements in test method is called multiple times. Why is this happening? Is DOM is recreated by AngularJS2 multiple times? import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `<div>Method Call {{test()}}</div>>` }) export class AppComponent { name = 'Angular'; test() { console.log("Test is called"); } } {{test()}} is evaluated every time Angular runs change detection, which can be quite often. Binding to function or methods from the view is discourages. Prefer assigning the result of the method call to a property and bind to this property instead.

{{ call() }} in template executes the method block multiple times?

蹲街弑〆低调 提交于 2019-11-28 08:27:34
问题 Here the statements in test method is called multiple times. Why is this happening? Is DOM is recreated by AngularJS2 multiple times? import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `<div>Method Call {{test()}}</div>>` }) export class AppComponent { name = 'Angular'; test() { console.log("Test is called"); } } 回答1: {{test()}} is evaluated every time Angular runs change detection, which can be quite often. Binding to function or methods from the view is