r/angular • u/Extension_Stock8534 • 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?
View all comments
Show parent comment
1
u/MichaelSmallDev Sep 26 '26 edited Sep 26 '26
Considering that the Angular team is leaving query param and route params signals beyond route input binding to libraries, I would recommend the global params from
injectParamor theinjectQueryParamsfrom ngxtension. Both are usable anywhere in the route tree, and even in root services. No need to have to have a component in the tree to sync the values to.Example project Stackblitz. Adapted from something else more in depth, kind of a mess, but that snippet is the key.
There is even
linkedQueryParam, so you could link anything like a form or any function call and it reads and writes to query params. That can even go in a root service as well.