How can I make it so I can subscribe to the "child" observables piped from the "parent" without firing the main ajax request?
Please see full working MVP example on StackBlitz if necessary.
@Component({
selector: 'my-app',
template: `
<h3>{{ title$ | async }}</h3>
<p>{{ value$ | async }}</p>
`,
})
export class AppComponent implements OnInit {
public response$: Observable<Response>;
public title$: Observable<string>;
public value$: Observable<string>;
constructor(private fakeAjaxService: FakeAjaxService) {}
ngOnInit(): void {
// call the main ajax request to populate the response$ observable
this.response$ = this.fakeAjaxService.request();
// pluck the title from the response
this.title$ = this.response$.pipe(pluck('title'));
// pluck the value from the response
this.value$ = this.response$.pipe(pluck('value'));
}
}
Thanks for any help!