dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

How to manually call PushUpdates from outside the BaseVM class #180

Closed cuongdn closed 5 years ago

cuongdn commented 5 years ago

Hello, Is there any way to call PushUpdates outside BaseVM like below tutorial (using Hub)?

https://docs.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-server#how-to-call-client-methods-and-manage-groups-from-outside-the-hub-class

dsuryd commented 5 years ago

If you're referring to server broadcast, look at MulticastVM.

cuongdn commented 5 years ago

I mean how can I get instance of view model so that i can call vm.PushUpdates(). Is there any method similar to GlobalHost.ConnectionManager.GetHubContext() to get view model instance?

dsuryd commented 5 years ago

There is no API to access a particular active view model. If you need to call PushUpdates from outside the view model, consider using the Observer pattern.