Am I using setTimeout in an inefficient manner?

Am I using setTimeout in an inefficient manner?

I have an angular app and I want to implement a 'Time Ago' feature. If I render some crazy number of 'questions', would this be a bad idea?

I have an angular app and I want to implement a 'Time Ago' feature. If I render some crazy number of 'questions', would this be a bad idea?

If you can imagine a facebook post that says 'posted about a minute ago...', that's what I'm shooting for.

The assumption is that the user never refreshed the page and the questions are appended to the angular mdoel from a signlar hub

export interface IQuestion {
  timeAgo: string;
}

export class Question implements IQuestion { public timeAgo: string; constructor(question: IQuestion) { this.timeAgoTicker(); } timeAgoTicker(): void { this.timeAgo = 'just now'; setTimeout( () => this.timeAgo = 'about a minute ago', 10000); setTimeout( () => this.timeAgo = 'a couple of minutes ago', 20000); setTimeout( () => this.timeAgo = '5 minutes ago', 50000); // etc... } }


javascript angular

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Install Angular - Angular Environment Setup Process

Install Angular in easy step by step process. Firstly Install Node.js & npm, then Install Angular CLI, Create workspace and Deploy your App.

Basics of Angular: Part-1

What is Angular? What it does? How we implement it in a project? So, here are some basics of angular to let you learn more about angular. Angular is a Typesc

How to Build an Angular Application with Angular CLI

How to set up the Angular CLI and generate a Trivial App

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

Angular Sass: How To Use Sass In Angular 9 Tutorial

Sass in Angular is an extension of CSS that allows you to use things like variables, nested rules, inline imports. Angular supports Sass, CSS, and Less.