Higher-level pattern for async data loading
We've had an internal request to consider ways of loading data without having to implement the usual if (data == null) { loading... } else { show data } in the markup, possibly also without overriding OnInitAsync or similar to put in the load logic.
Sketch:
<DataSource Url="people/@id" TResult=Person>
<BeforeLoaded>Loading person @id...</BeforeLoaded>
<OnError>Sorry, there was a problem. The response was @context.StatusCode.</OnError>
<AfterLoaded Context="person">
@person.Name is @person.Age years old
</AfterLoaded>
</DataSource>
This doesn't really have to be baked into the core, but we might want this to appear in the default project template.
Looks nice but please remember about authentication. Application can read data from different data sources and each one can require different authentication (JWT token) or some special request headers. Of course it is good to have a single sign-in experience, but it is not always possible.
it might be better to mark the property as Async and conditionally render, only after the property has value
Hi. Thanks for contacting us. We're closing this issue as there was not much community interest in this ask for quite a while now. You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.