Being totally new into node.js environment and philosophy i would like answers to few questions. I had downloaded the node.js for windows installer and also node package man
In my case I did it to loop for ever and show in the console a number ever in a single line:
class Status {
private numberOfMessagesInTheQueue: number;
private queueName: string;
public constructor() {
this.queueName = "Test Queue";
this.numberOfMessagesInTheQueue = 0;
this.main();
}
private async main(): Promise {
while(true) {
this.numberOfMessagesInTheQueue++;
await new Promise((resolve) => {
setTimeout(_ => resolve(this.showResults(this.numberOfMessagesInTheQueue)), 1500);
});
}
}
private showResults(numberOfMessagesInTheQuee: number): void {
console.clear();
console.log(`Number of messages in the queue ${this.queueName}: ${numberOfMessagesInTheQuee}.`)
}
}
export default new Status();
When you run this code you will see the same message "Number of messages in the queue Test Queue: 1." and the number changing (1..2..3, etc).