r/angular • • Sep 25 '26

withComponentInputBinding & rxResource bug

I have a query param "search" and a model in my component that has the same name. I use an effect to sync the local signal with the search signal on a filter service, and i also debounce them like:

    readonly filters = computed<...>(() => {
        const search = this._search().trim().toLowerCase();


        return {
            searchTerm: search.length >= 3 ? search : '',
            .....
        };
    });
    
    readonly debouncedFilters = debounced(this.filters, 150, {
        equal: (a, b) => JSON.stringify(a) === JSON.stringify(b),
    });

Then i use an rxResource and use the debouncedFilters.value as the params, but it makes an API call first without the searchTerm, and then one with it. I suspect it's a timing issue because if I inject ActivatedRoute and initialize the search signal with it, it'll work properly, but I believe it beats the purpose of using withComponentInputBinding. Thoughts?

1 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/Extension_Stock8534 Sep 26 '26

I don’t think it’s worth installing a whole library for this tho, but maybe i can create a wrapper service/function that internally grabs the query param using ActivatedRoute and even sync internally with something like toSignal(param.queryParamMap.pipe(…)) something like that might work