I think this is more of a TypeScript question, but what is the best way to wait for two events? For example, you subscribe for the a UI component ready event and wait for a “then” for a REST API’s return.
Obviously, to display the data from the REST API on the UI component, both need to be ready. Naively, I thought of this, but is this the best?
- On the UI component’s ready event, check if the data cache is ready. If so, display the data. Else, just set a variable “isUIReady” to true.
- On the REST API’s “then”, check if “isUIReady” is true. If true, display the data. Else, cache the data to a variable.