Best practice for setting query options that require an input parameter #159
Answered
by
NetanelBasal
unifyiGreenleaf
asked this question in
Q&A
Replies: 2 comments 2 replies
-
import { computedAsync } from 'ngxtension/computed-async';
export class ProjectMetricComponent {
projectId = input.required<Project['id']>();
readonly #projectService = inject(ProjectService);
projects = computedAsync(() => this.projectService.listProjectMetrics(this.projectId()).result$);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
unifyiGreenleaf
-
I'd be interested in the other side of this - to get ultimate signal being autoupdated with query result on parameter change |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
working on migrating some code to use query. and wonder what the best practice was for setting up a query and detecting changes when using inputs. I currently have this as a code which does work but I'm not sure if it's the best practices with passing null as the Id to the query. left out the template of the component but it follows what is in the README for signals with the
result.isLoading
,result.data
, etc...I had tried to set up the signal effect to set the #query property so I didn't have to use null as an id by doing the following. but in this case the query never fires.
I was trying to base my solution off the dynamic example but I don't have a route to pull from so I'm confused on what to do with the initial ActivateRoute part that exists in the example.
Beta Was this translation helpful? Give feedback.
All reactions