Reputation: 17
I wish to create and start a hub connection to my server when I navigate to a certain page, but I'm unsure of the best way to do this in a somewhat MVVM way. I was initially going to set up and start the hub connection in the view model constructor but should I instead override a method in the code behind such as OnAppearing()? Where does the hub connection belong?
Thanks.
Upvotes: 0
Views: 293
Reputation: 1631
My understanding is the VM and code behind are essentially the same (VM is a decoupled version of code behind so that you can re-use it with other screens, but in the real world that rarely happens - not worth the boilerplate IMO). I would suggest putting it wherever it is easiest for you to maintain and future developers to find.
Upvotes: 1