Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to send just a token via the MVVM Light Messenger?

I've been refactoring some code that was originally using the Messenger in MVVM Foundation to now use the Messenger in MVVM Light Toolit. One thing that I can't seem to find an equivalent for is the case where all you want to do is send a Token (i.e, the Token is acting as both a unique identifier for the message and the message itself).

Original Code (MVVM Foundation) - one string 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?

// send code
mvvmLightMessenger.Send("QuestionTimedOut", "QuestionTimedOut");

// register code
mvvmLightMessenger.Register<string>(
    this,
    "QuestionTimedOut",
    token => UpdateOnQuestionTimedOut());

I realize I could explicitly new up a NotificationMessage but that would add even more code.

like image 623
devuxer Avatar asked Jan 05 '11 00:01

devuxer


1 Answers

Good point. I put that on the backlog for MVVM Light VNext.

like image 147
LBugnion Avatar answered Oct 13 '22 19:10

LBugnion