Angular v22: Explaining debounced Resource — DeepSeek Tips…
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogAngular v22: Explaining debounced Resource
    Back to Blog
    Angular v22: Explaining debounced Resource
    angular

    Angular v22: Explaining debounced Resource

    Suguru Inatomi April 28, 2026
    0 views

    In Angular v22, it looks like debounced will be newly added to the Signals API family. I’ll explain...


    title: Angular v22: Explaining debounced Resource published: true date: 2026-04-08 02:03:00 UTC tags: Angular,Signals,StateManagement canonical_url: https://blog.lacolaco.net/posts/angular-debounced-resource.en

    In Angular v22, it looks like debounced will be newly added to the Signals API family. I’ll explain the use cases and the mechanism for this API.

    <iframe src="/embed?url=https://github.com/angular/angular/commit/b918beda323eefef17bf1de03fde3d402a3d4af0" loading="lazy"></iframe>

    debounced()

    The debounced function returns a Resource object with a certain wait time when changes to the source Signal are high-frequency. After a change to the source occurs, the value is finalized if no additional changes happen during the wait time. The mental model is similar to debounce in jQuery or RxJS.

    export function debounced<T>(
      source: () => T,
      wait: NoInfer<number | ((value: T, lastValue: ResourceSnapshot<T>) => Promise<void> | void)>,
      options?: NoInfer<DebouncedOptions<T>>,
    ): Resource<T>
    

    The following pseudo-code illustrates the behavior. While a Signal is a data model that always returns values synchronously, what the debounced function returns is a Resource object. Its value property returns a Signal that doesn’t change during the wait time. During the wait time, the isLoading property of the Resource will also be true.

    const source = signal('initial');
    const res = debounced(source, 200);
    
    source(); // => initial
    res.value(); // => initial
    res.isLoading(); // => false
    
    source.set('updated');
    source(); // => updated
    res.value(); // => initial
    res.isLoading(); // => true
    
    tick(200);
    
    source(); // => updated
    res.value(); // => updated
    res.isLoading(); // => false
    

    The primary concrete use case will likely be integration with Signal Forms. In cases where an HTTP request is triggered based on a Signal bound to a text field, you’ll want to debounce the user’s input. For example, you can create an HTTP Resource that calls an API with the value after waiting for a 200ms interval from the username field input, like this:

    const usernameForm = form(signal('foobar'));
    const res = httpResource(() => `/api/users/${debounced(usernameForm.value, 200)}`);
    

    A similar use case is asynchronous validation in Signal Forms. This has been added as a built-in feature where a debounce option is available in the validateHttp function, allowing for HTTP-based validation by debouncing form value updates. Internally, the debounced function is being called.

    const usernameForm = form(
      signal('foobar'),
      (p) => {
        validateHttp(p, {
          request: ({value}) => `/api/check?username=${value()}`,
          debounce: 50, // Short debounce
          onSuccess: (available: boolean) => (available ? undefined : {kind: 'username-taken'}),
          onError: () => null,
        });
      },
      {injector},
    );
    
    <iframe src="/embed?url=https://github.com/angular/angular/commit/24e52d450d201e3da90bb64f84358f9eccd7877d#diff-40702c7e3d12dc92f4ddf6e85452d6359479f4c0fc98ef0bb7c2e086cbeb0bb0" loading="lazy"></iframe>

    I think this mostly explains what the debounced function is. From here, let’s look at its mechanism.

    Mechanism

    As in the example where I wrapped Firestore the other day, Resource is an interface, and you’re free to choose how to construct it. Even if you don’t use the built-in resource or httpResource functions, you can still create objects that follow the Resource interface. While the actual debounced function has a complex implementation including fine-grained error handling within the framework, let’s try to understand the mechanism by creating a simplified version of a debounced function ourselves.

    First, as a base form, let’s create a function that returns a Resource that doesn’t do anything. From Angular v21.2 onwards, you can use the resourceFromSnapshots function to convert a Signal of a specific type into a Resource.

    function debounced<T>(source: () => T): Resource<T> {
      const state = signal<ResourceSnapshot>({
        status: 'resolved',
        value: untracked(() => source()),
      });
      return resourceFromSnapshots(state);
    }
    
    <iframe src="/embed?url=https://angular.dev/api/core/resourceFromSnapshots" loading="lazy"></iframe>

    With just this, changes to the source won’t propagate to the Resource. We need to use an effect to update the state when the source changes.

    function debounced<T>(source: () => T): Resource<T> {
      const state = signal<ResourceSnapshot>({
        status: 'resolved',
        value: untracked(() => source()),
      });
      
      effect(() => {
        const changedValue = source();
        
        state.set({
          status: 'resolved',
          value: changedValue,
        });
      });
      
      return resourceFromSnapshots(state);
    }
    

    Next, we’ll introduce a wait time. By accepting an interval as an argument and passing it to setTimeout, we can delay reflecting the value in the state. While it’s delayed, we’ll keep the state in a loading status.

    function debounced<T>(source: () => T, wait: number): Resource<T> {
      const state = signal<ResourceSnapshot>({
        status: 'resolved',
        value: untracked(() => source()),
      });
      
      effect(() => {
        const changedValue = source();
        
        setTimeout(()=> {
          state.set({
            status: 'resolved',
            value: changedValue,
          });
        }, wait);
        
        state.set({
          status: 'loading',
          value: state.value(),
        });
      });
      
      return resourceFromSnapshots(state);
    }
    

    Currently, it’s just delaying. If an additional change is triggered during the delay, we need to discard the ongoing wait time and wait for the value to stabilize again. To maintain this asynchronous state, let’s introduce local variables called activePromise and pendingValue. In the delayed callback via setTimeout, if the active matches, it means no additional changes occurred.

    function debounced<T>(source: () => T, wait: number): Resource<T> {
      const state = signal<ResourceSnapshot>({
        status: 'resolved',
        value: untracked(() => source()),
      });
      
      effect(() => {
        const changedValue = source();
        
        const waiting = new Promise(resolve => {
          setTimeout(resolve, wait)
        });
        
        const activePromise = waiting;
        const pendingValue = changedValue;
        
        waiting.then(() => {
          // If there is an intervening change, activePromise will mismatch
          if (waiting === activePromise) {
            state.set({
              status: 'resolved',
              value: pendingValue,
            });
          }
        });
        
        state.set({
          status: 'loading',
          value: state.value(),
        });
      });
      
      return resourceFromSnapshots(state);
    }
    

    Now our simplified debounced function is complete. Although it differs from the actual framework implementation in the finer details, the basic design looks like this. The internals are simple, just managing state with a Promise and a timer.

    What I’m trying to say is that creating a function that returns a Resource type is easy. When you want to integrate processing with asynchronicity into a Signal, the hurdle to creating your own is low, even if the built-in APIs don’t fit perfectly. One example of that was turning the Firestore Collection into a Resource in my previous post.

    <iframe src="/embed?url=https://blog.lacolaco.net/posts/angular-firestore-resource-signal" loading="lazy"></iframe>

    Summary

    • The debounced() function expected to be introduced in Angular v22 takes a high-frequency Signal as input and returns a Resource that finalizes the value once it has settled for a certain period.
    • Typical usage is “debouncing input,” such as HTTP Resources linked to form inputs or asynchronous validation in Signal Forms.
    • The key point of the implementation is monitoring input changes with an effect, managing the latest wait using a timer and a Promise, and updating the ResourceSnapshot to resolved when finalized.
    • Creating a function that returns a Resource type is not difficult. It’s a useful interface that can be used to integrate asynchronous data sources with Signal.

    Tags

    angularsignalsstatemanagement

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • Automate Blog Content Creation with Notion MCP, DeepSeek AI, and WordPressn8n · $9.99 · Related topic
    • Generate AI Videos from Scripts with DeepSeek, Synthesia, and Together.ain8n · $24.99 · Related topic
    • Compare Multi-Period Financial Data from Google Sheets with DeepSeek AI Analysisn8n · $14.99 · Related topic
    • PostgreSQL Conversational Agent with Claude & DeepSeek (Multi-KPI, Secure)n8n · $14.99 · Related topic
    Browse all workflows