Hello Nativescript Team,
I seem to be stuck with making method calls in my code.
Could you please provide me with guidance on how to implement synchronous method calling in Nativescript + Angular?
import { Component, OnInit, AfterContentInit } from "@angular/core";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit, AfterContentInit {
constructor() {
this.firstMethod();
this.secondMethod();
this.thirdMethod();
this.fourthMethod();
}
ngOnInit(): void {
this.firstInitMethod();
this.secondInitMethod();
this.thirdInitMethod();
this.fourtInitMethod();
}
private firstInitMethod() {
console.log("1 ::::: firstInitMethod method");
}
private secondInitMethod() {
console.log("2 ::::: secondInitMethod method");
}
private thirdInitMethod() {
console.log("3 ::::: thirdInitMethod method");
}
private fourtInitMethod() {
console.log("4 ::::: fourtInithMethod method");
}
private firstMethod() {
console.log("1 ::::: First method");
}
private secondMethod() {
console.log("2 ::::: second method");
}
private thirdMethod() {
console.log("3 ::::: third method");
}
private fourthMethod() {
console.log("4 ::::: fourth method");
}
ngAfterContentInit() {
console.log("ngaftercontnet init method called");
this.firstAfterInitMethod();
this.secondAfterInitMethod();
this.thirdAfterInitMethod();
this.fourthAfterInitMethod();
}
private firstAfterInitMethod() {
console.log("1 ::::: firstAfterInitMethod method");
}
private secondAfterInitMethod() {
console.log("2 ::::: secondAfterInitMethod method");
}
private thirdAfterInitMethod() {
console.log("3 ::::: thirdAfterInitMethod method");
}
private fourthAfterInitMethod() {
console.log("4 ::::: fourthAfterInitMethod method");
}
Output result:
[My Phone 5508]: 1 ::::: First method
[My Phone 5508]: 2 ::::: secondInitMethod method
[My Phone 5508]: 3 ::::: thirdInitMethod method
[My Phone 5508]: 3 ::::: third method
[My Phone 5508]: 2 ::::: second method
[My Phone 5508]: 4 ::::: fourtInithMethod method
[My Phone 5508]: 4 ::::: fourth method
[My Phone 5508]: ngaftercontnet init method called
[My Phone 5508]: 1 ::::: firstAfterInitMethod method
[My Phone 5508]: 2 ::::: secondAfterInitMethod method
[My Phone 5508]: 1 ::::: firstInitMethod method
[My Phone 5508]: 3 ::::: thirdAfterInitMethod method
[My Phone 5508]: 4 ::::: fourthAfterInitMethod method
I am looking for a way to synchronously call the methods as follows :
First methods in Contructor()
this.firstMethod();
this.secondMethod();
this.thirdMethod();
this.fourthMethod();
Second methods in Init
this.firstInitMethod();
this.secondInitMethod();
this.thirdInitMethod();
this.fourtInitMethod();
Third methods in AfterInit
this.firstAfterInitMethod();
this.secondAfterInitMethod();
this.thirdAfterInitMethod();
this.fourthAfterInitMethod();