When loading my component, the data is retrieved by first accessing ActivatedRoute.queryParams and then making an API call. Since using both an async constructor and an async call inside ngOnInit won't work to defer component initialization, I have to deal with the scenario where my data is undefined, leading to multiple tedious if statements.
An alternative approach is to avoid using this.data and instead pass the data as an argument to my class methods. By having a single check *ngIf="data != null" at the template root, passing non-undefined data around eliminates the need for null checks.
However, this may not be the ideal usage of class fields. So, what is the recommended way to handle asynchronously initialized component data?
I have considered implementing a ready flag and informing TypeScript that if ready is truthy, then data is not undefined. But I am unsure how to implement this effectively.