Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class MyMessage { }
public class DashboardViewModel : ViewModelBase
{
public DashboardViewModel()
{
MessengerInstance.Register<MyMessage>(this, OnMyMessage);
// lub MessengerInstance.Register<MyMessage>(this, "myToken", OnMyMessage);
}
private void OnMyMessage(MyMessage obj)
{
// ...
}
}
public class OtherViewModel : ViewModelBase
{
public void SomeMethod()
{
MessengerInstance.Send(new MyMessage());
// MessengerInstance.Send<MyMessage, DashboardViewModel>(new MyMessage()); // dla konkretnego odbiorcy
// MessengerInstance.Send<MyMessage>(new MyMessage(), "myToken"); // wiadomość otrzymają tylko subskrybenci z takim samym tokenem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment