-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
In Svelte you have really nice {#await} blocks which makes the markup very readable and the intent obvious. I think a lot of developers for blazor defer to having the collection or data as nullable and using that check for it. @if(collection != null) {data} else {skeleton}
It would be nice to just be able to @await(task1 && task2) and render the markup when the Task completes. The @await block could infer it's a Task.WhenAll
by default. This could improve designs of scoped services typically used to populate the data since it's a common pattern to return cached data and not need to run the task subsequently by returning the result.
Nullable could also be inferred as some different meaning context in the application, not necessarily has this loaded, but is this valid at all. It opens up more opportunities for devs to implement things.
Describe the solution you'd like
@await markup that compiles down to Task.WhenAll over any Task to indicate loading states
Field assignment of private variables so you can do @await(collection1 = _collection1, collection2 = _collection2) which keeps the current blazor structure intact that wants to iterate over member variable collections
Additional context
It might be nice to not care about the nullability as much and focus the front end on if the operation has completed, particularly in WASM scenarios, it feels like we could streamline the nullability checks with just awaiting the thing we want to happen, and this is also applicable to the server models, or desktop hybrid models when there's an expensive fetching operation.