jspuij / Cortex.Net

State management like MobX for .NET and Blazor

Home Page:https://jspuij.github.io/Cortex.Net.Docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Initializing store properties from asynchronous source

WhitWaldo opened this issue · comments

First of all, I've really been enjoying the ease of use of this library, so thank you for putting it together.

Especially since I'm utilizing C#'s nullable functionality, I'm seeing warnings for failing to make properties nullable and not setting the values in the constructor. Now, if I were to set the values in the constructor, I could do so synchronously and this wouldn't be much of an issue. However, given the documentation about the use of asynchronous methods, I wanted to see if there's any reason I shouldn't initialize the values in a Store in the constructor using Task.Run - if there is such a reason, what's the intended way that I should set initial values asynchronously (e.g. from an external store)?

Thank you!

Seems to work fine using Task.Run(async () => _remote.Get()}.Wait(), so closing as a non-issue.