I refactored the code that I originally used Messengerin the MVVM Foundation, now uses it Messengerin the MVVM Light Toolit. One thing I cannot find an equivalent for is the case when all you want to do is send a token (i.e. the Token acts as a unique identifier for the message and the message itself).
Original code (MVVM Foundation) - one line does it all
// send code
mvvmFoundationMessenger.NotifyColleagues("QuestionTimedOut");
// register code
mvvmFoundationMessenger.Register(
"QuestionTimedOut",
() => UpdateOnQuestionTimedOut());
New code (MVVM Light) - is there a more elegant solution than this?
mvvmLightMessenger.Send("QuestionTimedOut", "QuestionTimedOut");
mvvmLightMessenger.Register<string>(
this,
"QuestionTimedOut",
token => UpdateOnQuestionTimedOut());
I understand that I could explicitly update NotificationMessage, but this will add even more code.
source
share