Skip to main content
Filter by
Sorted by
Tagged with
Best practices
0 votes
3 replies
72 views

I am planning to implement pagination into my project for my data from Supabase, I had the idea that since there are different parameters (such as search text, page number, filter) that I should use ...
1million_ naira's user avatar
1 vote
3 answers
92 views

I created an intro/splash screen component that should display for 5 seconds and then automatically navigate to the login page. The strange thing is: If I don’t use setTimeout, Angular correctly ...
Giorgio Bonacorsi's user avatar
2 votes
1 answer
149 views

I'm running the code below. The output I was expecting was: Start -> End -> While expires -> joke -> setTimeout However, the output I’m actually getting is: Start -> End -> While ...
Interstellar's user avatar
0 votes
0 answers
53 views

I'm trying to understand how setTimeout works inside a loop in JavaScript. I expected it to print numbers from 1 to 5, each printed after one second, but instead, it prints the number 6 five times. ...
Annadanapu Mahitha's user avatar
0 votes
0 answers
35 views

I’m trying to understand the difference in behavior between let and var inside a for loop, especially when used with setTimeout. Here’s a simple example: for (var i = 0; i < 3; i++) { setTimeout((...
Ritam Laha's user avatar
2 votes
3 answers
104 views

I've been writing a userscript for a site and I want to show an update notification while the user is tabbed off of the site, and I came up with an idea to use the site title for that. This is my ...
ccjt's user avatar
  • 35
0 votes
1 answer
88 views

I have an Angular App with a custom error handler which works fine. Errors like these are caught: throw new Error('This error gets passed to the custom error handler'); this.zone.runOutsideAngular(() ...
DerZyklop's user avatar
  • 3,842
0 votes
1 answer
72 views

I have a piece of code which needs to be rendered using a typewriter effect. Basically, they are API responses similar to a GPT app. The code I have does the trick but while rendering the first case, ...
arunmmanoharan's user avatar
-1 votes
1 answer
138 views

Following the Stripe documentation I come to create a webhook endpoint on my app to catch the customer.subscription.created event, which I use as a signal to create a new account in my database. I'm ...
Alejandro Guajardo's user avatar
0 votes
1 answer
93 views

Browsers have a window.stop() function which I have overwritten for my own purposes: window.stop = (s,t,o,p=window) => { ... }; I'm trying to troubleshoot why calling my stop() function does not ...
Jamesfo's user avatar
  • 614
0 votes
2 answers
94 views

I have an array in state: const [show, setShow] = useState([false, false, false, false]) These affect whether or not an image is displayed. I'd like to iterate through them one by one, using a delay ...
Maccles's user avatar
  • 131
1 vote
0 answers
54 views

I have two questions regarding the following socket.io code snippet: const withTimeout = (onSuccess, onTimeout, timeout) => { let called = false; const timer = setTimeout(() => { if (...
LudarA's user avatar
  • 11
1 vote
0 answers
39 views

I was wondering if timers are actually part of event-driven architecture in Node.js. However, I haven't found anything mentioning it in the official Node.js documentation. Does it actually emit any ...
sebkaminski16's user avatar
0 votes
0 answers
34 views

I’m using the worker-timers npm package in a Vue 3 + TypeScript application to implement a lock/unlock mechanism of notes using Ably (where the notes are shared between multiple users). The idea is ...
Alex's user avatar
  • 2,082
0 votes
0 answers
66 views

When A WebViewController push B WebViewController, the settimeout function in A WebViewController will be stop working until returning to A WebViewController. On a PC, switching tabs in a WebView does ...
Crystal Black's user avatar
0 votes
1 answer
65 views

I'm trying to delay the execution of the setInterval function, which is set at 2000. Ideally, I would like the function to be executed after 10000 at every refresh of the page + after each hide on ...
soph.a's user avatar
  • 25
0 votes
2 answers
84 views

the idea of the code is simple. It will go to the search's page, "see" all the products there, click one by one, scrape all the data, go back to the search's page and click on the next ...
André's user avatar
  • 17
2 votes
1 answer
125 views

I am having a hard time with wait loops in JavaScript to wait for content from an external source (tasker). In particular I have an HTML document with JavaScript (shown in a WebView element inside a ...
Philipp Mayer's user avatar
0 votes
0 answers
46 views

I am trying to handle individual promises in a React app, and list their current state in a list on the App. I have two components : InstructionList : has the job to show and update a list of <...
Babidi's user avatar
  • 31
0 votes
0 answers
70 views

There is a website, it is connected to the OpenAI Speech API on the server, the server accepts a POST request from the frontend, which contains the text that needs to be voiced, the API voices it and ...
Igor's user avatar
  • 17
0 votes
1 answer
220 views

I have found contradicting information regarding timing with requestAnimationFrame in JS and would appreciate some help. In this post (1 Exact time of display: requestAnimationFrame usage and timeline)...
Thomas Gebetsberger's user avatar
0 votes
0 answers
89 views

I am using vanilla JS, webaudioAPI and canvas elements to create an audio visualizer. When I update the audio element src with javascript, I need the audio element duration property to update two ...
gbabyblue's user avatar
0 votes
3 answers
155 views

Code: setTimeout(() => console.log("1"), 1000) const startTime = Date.now() while (Date.now() - startTime < 5000); setTimeout(() => console.log("2"), 0) setTimeout(() => console.log("...
Vadim Sheremetov's user avatar
-2 votes
1 answer
82 views

Please see the below code. I thought the '11111111' line would never be executed but it is. Can anyone please explain. function outer() { function inner(dur) { console.log('in inner'); ...
rajplayster's user avatar
0 votes
0 answers
141 views

I am writing an expect script that helps me run a program. When i set the timeout to 10 or 30, the program runs although since it's a big run installation, it doesn't get completed within 30 seconds. ...
Priyansh Mehta's user avatar
0 votes
0 answers
54 views

Using jasmine and karma, I can pass the unit test using fake async and using a real event, but the coverage is not correct, the settimeout call back is ignored. @Component({ selector: 'slider', ...
Tabares's user avatar
  • 4,355
0 votes
1 answer
50 views

I want to display some messages in a sort off in app notification. It is supposed to behave like this: click on a button notification slides down + display text notification slides back up If there ...
Mateus Oliveira's user avatar
0 votes
1 answer
83 views

This function goes through the dataset and then sorts it in ascending order. What its meant to do is stop when the list has been sorted. However, the !changed control flow statement terminates it ...
That wolphin's user avatar
0 votes
0 answers
36 views

We have an in house js framework that contains JS functions specific to a number of controls that can be used on a page. Some of these controls need js initialising at different points i.e. immediate (...
Chris Spittles's user avatar
0 votes
1 answer
131 views

I’m using a Web Worker to set a setTimeout that automatically logs out the user after 10 minutes of inactivity. However, I’ve encountered an issue where if the user’s computer goes to sleep, all ...
YI LU's user avatar
  • 21
-1 votes
1 answer
114 views

Consider a scenario where I have two tasks - Task 1 is a callback which is set to be executed after 1 sec using setTimeout. Task 2 is a synchronous/blocking task which takes comparatively more time ...
Arman Lalani's user avatar
1 vote
1 answer
96 views

I'm trying to iterate through radio buttons automatically every 5 seconds via jquery; however i need the function to also run when i manually switch buttons. Here's what I have so far: $(document)....
amy's user avatar
  • 83
0 votes
0 answers
68 views

Here I have perform testing on jest. When I tested for setTimeout() function, it didn’t work. Any help would be appreciated. I have followed this documentation: https://jestjs.io/docs/timer-mocks ...
Jay Patel's user avatar
1 vote
3 answers
51 views

My code works fine, but it never ends. How can I stop the rotator after Word6? I have tried one more setTimeout but it's not working. const phrases = ['Word1', 'Word2', 'Word3', 'Word4', 'Word5', '...
Andreas Thomsson's user avatar
-1 votes
2 answers
108 views

I have a simple program that looks like this: console.log("Start of the program execution!"); setTimeout(() => { console.log("I ran after a second!"); }, 1000); console....
mukesharyal's user avatar
0 votes
1 answer
166 views

I have an Angular component where I want to use scrollIntoView when the route changes. Here's the relevant code snippet from my component: @ViewChild('structure') structure: ElementRef | undefined; ...
Apurv's user avatar
  • 1
1 vote
1 answer
52 views

I have the following Angular2 'pseudo' code and I want to keep the user class as simple as possible: // ###### LIB CLASSES ###### @Component() export abstract class Parent { abstract ...
jan dolezal's user avatar
1 vote
3 answers
74 views

I need a function to print numbers from 1 to 10 every ms using recursion. My function prints numbers ​​from 2 to infinity, probably, although the condition for exiting the recursion is written. What ...
Valentina's user avatar
2 votes
1 answer
424 views

In my program, I use the alternate setTimeout function (returns a promise, does not take callbacks) from timers/promises to avoid recursively calling the standard setTimeout function. I'm doing some ...
Michael Goldstein's user avatar
0 votes
3 answers
72 views

I'm encountering an issue with closing a child window inside a setTimeout callback in JavaScript. Despite successfully opening the child window using window.open, I am unable to access the newChild ...
laktherock's user avatar
0 votes
3 answers
174 views

I have a JavaScript function of chrome extension that I need to run at exact 5-minute intervals, synchronized with the current time. For example, it should run at 5:00, 5:05, 5:10, and so on, ...
Hamed's user avatar
  • 41
0 votes
1 answer
92 views

I'm encountering an issue with setTimeout function where it doesn't seem to reflect the updated value of a variable. Here's a simplified version of my code: const handleProcessError = (processName, ...
Prashant Kumar's user avatar
-1 votes
2 answers
99 views

Goal: Delay execution of function by at least 1 second. The problem: Instead of a minimum 1 second delay the do {} while loops forever. The steps: After 1 second timer is set to timerLength. If the ...
myNewAccount's user avatar
-1 votes
1 answer
111 views

I have function setTimeout in JS: Interval = 20000; timer = setTimeout(function loop(){ //do something timer = setTimeout(loop, Interval); }, 1); $("#next_button")....
user3446272's user avatar
-1 votes
1 answer
143 views

I have the below code snippet in NodeJS. console.log("START"); setImmediate(() => { console.log("setImmediate 1"); }); setTimeout(() => { console.log("setTimeout 1&...
KK2491's user avatar
  • 508
2 votes
1 answer
65 views

I wrote a utility function to create an async timeout: export function asyncTimeout(timeout: number): Promise<void> { return new Promise(resolve => setTimeout(resolve, timeout)) } I also ...
Mohammad Javad Khademian's user avatar
1 vote
1 answer
147 views

So I am working on a project and after routing was implemented a component has broken. On one component I have used a promise delay to hold off some DOM manipulation (adding a class to an element) ...
I2obiN's user avatar
  • 309
0 votes
1 answer
78 views

I have an AJAX call, and the result is processed by a callback. This may be real quick, or take some time. If the callback lasts more than 3 seconds, I want to display an image (or a text) that tell ...
Congregator's user avatar
2 votes
3 answers
266 views

In this code: setTimeout(() => console.log('C'), 100); setTimeout(() => console.log('D'), 0); const t1 = new Date(); while (new Date() - t1 < 500) {/* block for 500ms */} This will log D -&...
lynxx's user avatar
  • 614
2 votes
0 answers
86 views

let c = document.querySelector(".imge"); c.addEventListener("dragstart", () => { setTimeout(() => { c.classList.add("hide") }, 0) }) .hide { display: none; } <img src="https://...
Ujjawal's user avatar
  • 61

1
2 3 4 5
108