C#C
C#5mo ago
Pablitux

.Net Channels and MVVM

I have a Background Service that receives information from a websocket endpoint in JSON format and deserializes it into types I defined, based on the value of the JSON's "action" property. So far, so good; the service works, and I can correctly deserialize each type. However, I've run into a problem. To send information to the endpoint, I use a method that simply sends the action, which is structured the same way I receive it. Since I'm only sending the information, I need a way to receive this information and queue it to be deserialized and stored in memory. I immediately thought of using Channels, which seems to accomplish this goal. Now, I need to create consumer logic that receives this information and stores it in a context. When the Background Service receives a different state, it notifies the context to update the state of this class. From what I've read about MVVM, you can do this by storing the states in view models. However, I'm unsure if I understand correctly what MVVM is for or how to implement all this logic. Can anyone help me?
Was this page helpful?