How to Inject Data into plain c# Entry Points #237
Replies: 1 comment 2 replies
-
Hmm. From looking at the sample code, your problem is not with the collection, but with the usage of async/await.
This line is probably a compilation error.
This line will go to the next line without waiting for DI constructs should be resolved statically. If you need to retrieve data dynamically at runtime, it is better to DI only that function. (e.g: class FooRepository
{
public DataCollection Collection { get; } = new DataCollection();
public async UniTask FetchAsync()
{
// Get the data asynchronously!
}
}
public FooService
{
public FooService(FooRepository repository)
{
this.repository = repository;
}
// ...
} In addition, retrieving data asynchronously requires complex controls, such as displaying screens while waiting, displaying errors, reloading, and retrying. |
Beta Was this translation helpful? Give feedback.
-
Hey there,
I'm new to DI and struggling to understand how to inject a data collection (List, Dictionary<T, T>) into LifeScope when retrieving the data relies on asynchronous methods.
`
`
and many other combinations, but haven't been successful.
Can you provide a simple example of how I can achieve this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions