I have a table with a list of objects, and I provide the user with an option to edit these objects. I don't know if I need to use the API in the parent (object list), in the child (object) or in both. Can I replace 2 calls to the API with 1 observer (rxjs) in the parent and one @Input in the child? Is this a good idea?
ParentList(){
listObjects$: Observable<Object[]>;
this.listObjects$.pipe(take(1)).subscribe(list => {
//Assign listObjects
});
}
ChildForm(){
@Input() object$!: Observable<Object>;
}
I actually tried calling the API service both times.
I would suggest to call the API either from child component or from parent component. I don't see a reason to call it from both.
Regarding whether to call it from the parent or child component, it depends: