Proof of concept project combining Stl.Fusion and Cortex.Net.
See the project Blazorise. It is an adaptation of Fusion's Blazorise todo list sample.
Key Benefits
- End-to-end Real Time, from database to multiple hosts and multiple Blazor clients; thanks to Fusion.
- The Cortex Store architecture enables:
- Isolation of UI state and update logic into an observable model.
- Efficient rendering without the need to implement Blazor's ShouldComponentRender nor to strategically call StateHasChanged.
- This translates to good scalability of complex user interfaces. All components can be simple, 'Pure'; free of complex code and side-effects or inter-component rendering dependencies. All logic is testable and delegated away into the Actions in the stores.
- Testing the stores is a good substitute for testing the actual Blazor components and much easier.
Done:
- created observable stores: AppStore and TodoPageStore
- AppStore has a simple timer and shows as a clock in the main layout
- TodoPageStore contains the client-side state for the todo page, such as current page size and page marker. It also contains a Fusion LiveState reference that is subscribed to changes impacting the TodoPageResponse. This DTO contains the currently visible todo-items and it is auto-requeried by Fusion when update command commands are executed that affect related data in the database.
- Extracted all logic from the todopage.razor and TodoItem.razor, making it a render-only component
- Testers still to be implemented.
Issues and Todos:
- When more than 5 (the default page size) todo's exist, The MORE button appears. It invalidates the LiveState which should trigger a recompute/fetch of the TodoPageResponse. However, this somehow is broken. Adding or updating an item will subsequently retrigger and show the increased page size. Needs analysis.
- WebAssembly mode fails on DI injecting ISessionProvider into the TodoPageStore. Needs analysis. Debug output: Cannot resolve scoped service 'Stl.Fusion.Authentication.ISessionProvider' from root provider.
- The Fusion Auth state is not yet live-plugged to the TodoPageStore, hence after login, the Todolist does not immediately appear yet.
- Fusion query and command errors are not tested and probably not working yet in the TodoPageStore