717 questions
Best practices
0
votes
3
replies
74
views
Using setTimeout within useEffect() to debounce searching in react native pagination
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 ...
-1
votes
1
answer
40
views
Make debouncing function on events
I have a parent component with two event functions handleMouseEnter and handleMouseLeave. The child component receives these two functions via props, so my goal is to make some delay in the execution ...
0
votes
1
answer
27
views
How to setvalue of a textarea instant and call api after 2 second for efficiency
I've a textarea and I'd like to udpate text area text instantly as user enter text but I don't like to hit api after every keystroke for obvious reason for efficiency.
I've tried to use debounce ...
0
votes
1
answer
68
views
Key-based debounce in Kotlin Flows
I have a flow of key-value pairs (e.g. Flow<Pair<String, Int>>) which I would like to debounce/throttle based on the key, so that when some sequence of pairs with non-unique keys comes I ...
1
vote
1
answer
85
views
Debounce Function in PowerShell
I'm attempting to create a simple debounce function in PowerShell. Here is what I have so far.
# timer.ps1
# Define debounce function
Function New-Debounce {
param(
[scriptblock]$...
0
votes
2
answers
127
views
How to test debouncing logic
I'm trying to use TDD to build a search view model that debounces before searching. Until recently I would have created a mock debouncer, injected it into my view model and used that to control the ...
0
votes
1
answer
299
views
Promise somhow escapes to event loop?
I need a self-contained abstraction for debouncing a function call. While deno/async provides such a function, AFAICT there is no way to cancel an already running function (for example, to kill a ...
0
votes
1
answer
129
views
Swift Debounce or delay with discriminator
My application includes various widgets indicating realtime values (temperature, cpu usage, memory, etc....).
These widgets are updated from JSON messages received through a single websocket.
At the ...
3
votes
3
answers
2k
views
Is there a way to debounce a Svelte 5 $derived value?
I tried with:
let searchText = $derived(debounce((typedText) => typedText, 2000)(typedText));
But searchText is not assigned!
Reproduction with $derived: searchText is not assigned.
Reproduction ...
0
votes
1
answer
78
views
Working of useSearchDebounce custom react hook
I found this code from this answer https://stackoverflow.com/a/68780417/26420821
How does it work?
export function useSearchDebounce(delay = 350) {
const [search, setSearch] = useState(null);
...
1
vote
1
answer
174
views
RxJS alternative to debounceTime operator, so items won't get collected?
RxJS pros out there, I need your help!
Based on my last question I'm now looking for something different:
Question: How to separate values of a stream, keep the last of each and force flush after a ...
2
votes
2
answers
184
views
In Swift, how to send network requests upon tap such that each request has a few seconds delay in between?
I have created this simple example to show the issue.
I have 4 buttons for upvoting, favouriting, flagging, and hiding. User can tap any button whenever they like and as many times as they want. ...
0
votes
0
answers
143
views
How to Optimize Search Query Handling with React Query v5 Library?
I'm currently working on implementing a search functionality using the React Query library in my application. While I have a basic implementation in place, I'm seeking advice on how to optimize the ...
0
votes
1
answer
81
views
React + FabricJS: Custom Scrollbar - Flickering Scroll Thumbs on zoom in/out state update
I made a Custom Scrollbar for FabricJS (Since they don't provide one). Everything seems to be working fine. The thumbs of the scrollbar do change their height and width when the zoom state updates, ...
2
votes
2
answers
528
views
Pass generic type T through withCheckedContinuation
I have a search for multiple types, so the general search method has a generic type T, and multiple simple methods call it specifying the type as needed. I'd like to delay search method's start (...
0
votes
1
answer
426
views
Debounce Slim Select Search Event with Stimulus Controller Ruby on Rails
Question forum on slim-select: https://github.com/brianvoe/slim-select/discussions/541
Hi, I'm using Ruby on Rails with Stimulus JS and have been using slim select for the past 6 months in my project. ...
0
votes
1
answer
141
views
How to remove AutoSuggestBox delay / debounce?
While using the AutoSuggestBox in e.g. the WinUI 3 Gallery app, I noticed that there is some kind of debouncing on the input. So if one types fast, the results are not updated until one stops typing. ...
0
votes
1
answer
43
views
Facing Issue in Debouncing concept in react
import React,{useState} from 'react';
const app = () =>{
const [inputValue,setInputValue] = useState();
const handleChange = (e)=>{
setInputValue(e.target.value);
...
0
votes
0
answers
39
views
How to debounce each iteration in the loop
I'm using lodash debounce function. My problem is that I don't know how to properly use debounce within for of loop so it debounces every iteration separately, not all loop at once.
Here is code of ...
0
votes
1
answer
573
views
How to implement debounce in React textarea?
I try to add debounce to handleInputChange in my React component. When user types in textarea, is shouldn't constantly rerender (I check it by console.log(commentBody), but maybe I'am wrong, I'm not ...
0
votes
1
answer
976
views
How to correct call API search request with debounce?
I tried to setup correct API call with debounce. Now I have function in ViewModel which call API search request with delay (debounce) and unique (latest) value, but as many as there are changes in the ...
0
votes
2
answers
184
views
React, how to check if state is remaining in certain value for certain time?
I have a state value, it may change from time to time. I want to have a flag that indicate "this state has been staying in value x without any changes for y amount of time"
How do I achieve ...
0
votes
3
answers
266
views
What is the difference when using throttle and useeffect settimeout for search
I am using useEffect and its working fine, but I am aked to use debounce insted. Should I just make the useEffect into a seprate/ reusable function?
const [query, setQuery] = useState('');
...
0
votes
1
answer
131
views
Debounce "setting" of values in proxy trap without delay/timeout
I try to understand how i can debounce a "set" trap in javascript proxy.
function debounce(func, wait, immediate = false) {
let timeout = null;
return function(...args) {
let ...
1
vote
0
answers
320
views
How come this `e.currentTarget` is null in debouncing function? [duplicate]
I made a debounce function in Vanilla JS to understand how debouncing function works.
<!-- index.html -->
<div>
<input id="text" type="text" />
</div>
// ...
1
vote
1
answer
384
views
Debouncing multiple calls with useCallback in React for independent updates
I'm facing a challenge with debouncing multiple calls to a function in a React component, where each call represents an update to the number of copies for a specific file. To implement debouncing, I'm ...
-2
votes
2
answers
349
views
Debounce method implementation in Javascript is not getting console
Following is my code implementation for which debounce in JavaScript is not working. I am trying to execute the function only after 3 sec delay. Let me know what I am doing wrong here.
Code -
...
0
votes
1
answer
342
views
Managing Cart Updates with React and Debouncing
I'm currently working on an e-commerce application using React, and I'm having issues managing cart updates when users add or subtract the quantity of items in their cart.
At the moment, I'm sending ...
-1
votes
1
answer
184
views
Lodash debounce is not working in react js
I'm trying to search for a product from my database and using lodash's debounce to send request after a certain time. The problem I'm facing is that the request is going after the specified time only ...
0
votes
2
answers
758
views
How to deal with debounced input in Cypress tests?
What is the recommended approach for dealing with a debounced input in Cypress E2E tests.
For example, let's assume I have the following component that uses lodash/debounce
import React, { useState, ...
2
votes
0
answers
300
views
Debounce google cloud function using Google Cloud tasks queue
I am trying to update lastMessage on a chatRoom, So every time a message is created in the subcollection of the chat room it sets it as lastMessage on the chatRoom.
In order to avoid unnecessary ...
1
vote
1
answer
405
views
How Can I Debounce User Input for Responsive Yet Efficient useEffect Triggering in React?
I'm currently working on a React project that utilizes React Router with react-router-dom. In one of my components, I'm using the setSearchParams function from useSearchParams to manage and modify URL ...
2
votes
1
answer
1k
views
How to use debounce with Tiptap
I am using Next in the frontend, convex in the backend to build a text editor.
Till now, I have made it so that when there is any update in the editor, I am updating the updated content to the ...
1
vote
0
answers
171
views
How to lazy load the data from useEffect?
So, in my code, i am loading the Select options and the options i am loading are based on the calculation of possibleSubnets for a netMask, for example /64 will have so many records in dropdown.
With ...
9
votes
6
answers
42k
views
Debounce in ReactJS
I am trying to implement debounce in my search input in React. The below code is causing the delay but its firing the same number of times.
Example - If I type abcd in less than 2 seconds(delay) my ...
1
vote
1
answer
986
views
Lodash debounce only delays for first call
I have an input box where the user can manually enter the quantity and also plus(+) minus(-) signs so that they can add/remove by clicking on the plus or minus signs.
What I am trying to achieve is ...
0
votes
1
answer
245
views
debouncing in react using useRef and useMemo
I am trying to implement debounce in react js , and I have written the following code .
import { useEffect, useRef, useState, useMemo } from "react";
function debounce(fn) {
let timer = ...
1
vote
0
answers
180
views
Debouncing in JS causes flickering in the component
I have a component where debounce is added for the onChange of an input component. This input component only takes numbers as input. While entering decimal value there is a flicker in the component.
...
1
vote
2
answers
693
views
Why is setting a React component in useState a bad practice?
Why is it bad practice to store a component as the state value?
const [Component, setComponent] = useState<JSX.Element>(<Empty />);
Say I want to conditionally render a component based ...
2
votes
1
answer
3k
views
Debouncing button in Flutter
How can i prevent the users to accidentally press twice on the button thus placing the same order twice, using debouncing with timer?
I actually tried using debouncing on the button but I couldn't ...
2
votes
1
answer
735
views
React Native with Lodash Debounce: useCallback or useMemo
I made a composant that run a search to an API once the text changes with lodash's debounce.
I made it works either by using useCallback and useMemo but I can't understand the differences (advantages/...
0
votes
1
answer
232
views
How to debounce/throttle this object prop method?
I'm using this javascript code for @tanstack/query IndexedDB persistance as documented here.
I'm having too much put() calls and I would like to throttle/debounce them.
How can I do this in the below ...
2
votes
1
answer
896
views
Failing to run a deboundced react onChange using vitest advanceTimersByTime
I have the test below
Which I am running on a reusable text field that has a debounce function as below (code slightly trimmed)
For some reason I keep getting the error below despite using vitest....
0
votes
1
answer
1k
views
Debounce is not working when i am trying to filter the search results by typing in the input
I am trying to filter my search results using debounce lodash. I ma able to filter but the debounce is not working the way it is supposed to. Every time I enter text in the input an API call is made.
...
1
vote
1
answer
1k
views
How to debounce 'onScroll' in react without using other libraries
the code below logs 'scrolled' to the console multiple times (at least 10 times), even though using monitorEvents() indicates a single keydown event.
how can i ensure only a single 'scrolled' gets ...
1
vote
1
answer
87
views
Is this case for debounce correct?
I practiced a debounce on bigfrontend, there is an example in the stem of the question, each dash represents the waiting time, the question is about the following
The question is https://bigfrontend....
0
votes
0
answers
303
views
How Do I Define player.Name?
I am trying to make a system where when a person steps on a part, they get 1 win, but when 2 people jump on it at the same time, it doesn't give the next person a point.
I tried a local player script ...
0
votes
1
answer
49
views
How To Allow 2 Roblox Players To Jump On A Part And Both Get A Win
My Problem is that when I try to script what I listed in the Title, it always gives a win to only one player when they both jump at the same time. I just need help to fix this and only give 1 win to ...
3
votes
1
answer
676
views
How to prevent input event from firing multiple AJAX requests within a short time?
I'm facing an issue with a JavaScript event where an AJAX request is sent multiple times when the event is triggered rapidly. Let's say I have an input field that triggers an AJAX request on the "...
1
vote
1
answer
377
views
How to debounce an async function or prevent it from being invoked a 2nd time before having finished fetching the first query from e.g. a database?
I'm using pinia store to fetch queries into firestore data base through this action ( async getdayAppointments(appointmentdate)) in the store but some times if the action is triggered two times in a ...