Why does a search box sometimes feel fast and sometimes slow? Think of typing on your phone - If your phone checks spelling every few letters while you type - that’s throttle. - If your phone waits until you stop typing for 2–3 seconds before checking - that’s debounce. I used these ideas to fix a slow search in some of our projects - Throttle is good when you need updates at regular intervals (like scroll events, live data, or APIs with limits). - Debounce is good when you only need the final action (like search suggestions, form checks, or auto-saving drafts). In React, we often use debounce from lodash to handle this. Along with that - Wrap functions in useCallback for stability - Clean up on unmount - Cancel timers when input changes This reduced server calls by ~70% and made the search feel smoother. In short Need steady updates? Use throttle. Need the last action after typing stops? Use debounce. #debounce #throttle
How to make your search box faster with throttle and debounce
More Relevant Posts
-
"Here is the thing : it does not make much sense to ask the user for the userAgent as we can infer it from the context (i.e. the browser they're using). This is where the fillingMode property is very handy. There are two possible values : AUTO_PRE : Set programmatically on behalf of the user before submitting the use case MANUAL (default) : Set manually by the user" Read more : https://lnkd.in/eGHeVYap
To view or add a comment, sign in
-
-
Amp CLI now has custom slash commands. They allow you to insert pre-defined or dynamically-generated text into the prompt input.
To view or add a comment, sign in
-
Use nameof() to Keep Code Clean Sometimes we write variable names as text: Console.WriteLine("user"); ❌ Problem: if you rename user, this text will not change → possible bugs. ✅ Solution: use nameof() void Save(User user) { ArgumentNullException.ThrowIfNull(user, nameof(user)); } Now if you rename user, this code updates automatically. Less bugs, cleaner code!
To view or add a comment, sign in
-
-
In my last post, I talked about Escape Analysis and how Go tries to minimize heap allocations to reduce GC work. But what if we know we’ll need the same objects repeatedly? 👉 That’s where sync.Pool comes in. A sync.Pool is a concurrent-safe pool of reusable objects. Instead of allocating a new object each time (and later letting GC clean it up), Go lets you borrow from the pool and put it back when done. Example : https://lnkd.in/ecTZGPzG 🔹 Without sync.Pool: every request allocates a new buffer → GC pressure. 🔹 With sync.Pool: buffers get reused → fewer allocations, less GC overhead. 📌 Takeaway: sync.Pool isn’t for caching forever — it’s for short-lived, temporary objects where reuse can dramatically improve performance. #Golang #Performance #BackendEngineering #Concurrency
To view or add a comment, sign in
-
🆕 ColdBox Free Tip #4 – Using a Struct for Query Strings Simplify your links by passing a struct to buildLink() instead of manually adding query parameters. ColdBox automatically generates clean, maintainable URLs for your applications. 🔗 Learn more: https://lnkd.in/dEckfs7K #ColdBox #CFML #DevTips #OrtusSolutions
To view or add a comment, sign in
-
Using static blocks for frequently changing content? The result: Manual maintenance of EVERY block instance The solution: Dynamic blocks Better: Synced patterns → global updates. When logic is needed: Dynamic blocks → PHP-powered output. Stop editing one by one. Use the right tool. Think dynamic. https://lnkd.in/d37kuigX
To view or add a comment, sign in
-
-
Skip List in cpp, for fast lookups. In-memory DB needs a fast lookups, inserts, and deletes in a concurrent setting, so we implemented a Skip List in C++. Unlike balanced trees (like Red-Black or AVL), a Skip List relies on probabilistic balancing. Think of it as a multi-level linked list where higher levels act as “express lanes,” allowing us to skip over large chunks of nodes. The beauty is in the simplicity: a. O(log n) average time complexity for search/insert/delete. b. Cache-friendly compared to trees. c. Natural candidate for concurrent or lock-free designs. Here’s a quick peek at the design: - Each node holds a Key–Value pair and multiple forward pointers. - The number of levels per node is chosen randomly (coin flip). - Over time, this randomness gives us a balanced structure without explicit rebalancing. You can check out the full implementation here. https://lnkd.in/gW_YFEUs #SystemDesign #Cpp #LLD #System #List #skiplist
To view or add a comment, sign in
-
Thrilled to share I've merged my first open-source contribution to Yazi, a lightning-fast terminal file manager written in Rust! 🚀 I’m excited to share that I just made my first contribution to open‑source! I added a useful feature to Yazi, a terminal-based file manager written in Rust, that displays task progression during Copy I/O operations. You can check out my pull request here: https://lnkd.in/gWdGgx9e Here’s what I learned from this experience, and what I think will be helpful for anyone diving into open‑source for the first time: 1. You don’t need to understand the entire codebase. Jumping into a large project can feel overwhelming. Instead, focus on understanding just the portion of the code that relates to your task—for example, how the input system works or where copy logic is implemented. 2. When in doubt, print (or log) your way through. If you don’t know when or why certain code is executed, sprinkle a few println!() statements around relevant sections. Seeing output in real time helps you follow the execution flow. Of course, using a debugger is powerful—but sometimes print statements are faster and clearer, especially in simpler contexts. 3. Stay focused on your goal: the issue or feature at hand. Keeping your attention firmly on the task you’re solving helps avoid getting lost in unrelated details. It keeps your contributions tight, efficient, and aligned with the project’s intent. TL;DR - 🚀 First open‑source contribution in Rust (Yazi file manager) - Added a task progress display during copy operations - Learned how to dive into big codebases, debug effectively, and stay goal‑oriented Open‑source can feel daunting—but even a small, focused feature counts. If you’re thinking about contributing, start small and stay focused. You’ll learn more than you expect—so take that first step!
To view or add a comment, sign in
-
VIM Essential Commands & Their Uses Modes • Normal Mode → Move around, run commands (default mode). • Insert Mode → For typing text (i to enter, ESC to exit). • Visual Mode → Select text (v to enter, ESC to exit). Movement • h → Move left • l → Move right • j → Move down • k → Move up • gg → Go to first line • G → Go to last line • (Or use arrow keys ↑ ↓ → ←) Saving & Quitting • :w → Save file • :q → Quit • :wq → Save and quit • :q! → Quit without saving Editing Insert text • i → Insert at cursor • a → Append after cursor • o → Open new line below • O → Open new line above Delete text • x → Delete character • dd → Delete line • dw → Delete word • u → Undo last change Searching & More • /text → Search for “text” • n → Next match • N → Previous match • yy → Copy line • p → Paste after cursor
To view or add a comment, sign in
-
-
🚀 Just shipped: A high-performance, multi-format file compression engine in C++! Tired of one-size-fits-all compression tools that don't understand your data? I've been building a professional-grade File Compressor designed to intelligently reduce file sizes by leveraging specialized algorithms tailored to each format's unique characteristics. This wasn't just about applying zip to everything. The core challenge was selecting and integrating the best-in-class libraries to achieve maximum efficiency for each file type: ✅ Text & Data (TXT, CSV, JSON, XML, LOG): Leveraged Zlib for robust lossless compression, achieving 60-85% reduction. ✅ Images (BMP, TIFF, PSD): Used stb and LibTIFF to intelligently convert BMPs to PNGs and compress TIFF/PSD files with up to 85% reduction. ✅ Audio (WAV, AIFF): Integrated LAME & AudioFile to transform uncompressed audio into efficient MP4 (AAC) files, slashing size by a massive 85-95%. 🛠️ Under the Hood: Modular C++ Architecture: Each format has its own dedicated compression module, making it easy to maintain and extend. CMake Build System: For seamless, cross-platform compilation. Professional Code Structure: Clean separation between source, headers, and external libraries. Although this is just the initial version of this project it was still fun to take a deep dive into the nuances of data formats, compression theory, and native library integration. It reinforced the principle that the right tool for the job will always outperform a generic solution. I'm excited to share the code and see how others might extend it. Think it could be useful? Check out the repo, I’d love your feedback on what other formats would you want this to support? Star ⭐ it if you like it, and I'm always open to feedback and collaboration! 🔗 Repository: https://lnkd.in/ge7k-zmv
To view or add a comment, sign in