Computed Signal Results Not Re-computing? #135
-
I am currently trying to create some computed signals from the result signal for a query. When the component loads, the computed calls to seem to run and return a value. However, when I perform a mutation, invalidate the query and refetches, the computeds do not update. appDataQueryResult = this.appDataQuerySvc.testQuery().result;
data = computed(() => {
console.log('Re-computing');
return this.appDataQueryResult().data;
});
title = computed(() => this.data()?.title);
description = computed(() => this.data()?.description);
archived = computed(() => this.data()?.archived); I have a feeling the computed might be memoizing the result and not recognizing changes in values as new signals. I cannot think of any other reason that computeds would not be executing after mutation and the data changes. I would at least expect a log stating "Re-computing" whenever the query result signal emits. I tried digging in the code for a bit but I was unable to make much headway even finding a cause. If this cannot be fixed due to Angular decisions around signal equality functions, I wonder if there is anyway to build selectors/slices into the queries? Here is a link for a stackblitz project where this problem is reproduced: https://stackblitz.com/edit/stackblitz-starters-7hrm4y?file=src%2Fapp%2Fapp.component.ts As with any other issue, I am hoping I am just doing something terribly wrong and can learn from it. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Also, I am unsure if this should have been opened as an issue instead. I am still new to the whole OSS environment. If this needs converted to an issue instead please let me know and I will do so :) |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Sure! Let me see what I can do :) |
Beta Was this translation helpful? Give feedback.
-
You are mutating the data. You need to do: archive(): Observable<null> {
this.data = {
...this.data,
archived: true
}
return of(null);
} |
Beta Was this translation helpful? Give feedback.
You are mutating the data. You need to do: