Created
June 7, 2014 19:08
-
-
Save Redth/a7442c6b437835b4b97d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MsgHub | |
{ | |
public static MsgHub Instance = new MsgHub(); | |
public static void Send<TArgs> (TArgs args) | |
{ | |
var msg = args.GetType ().Name; | |
MessagingCenter.Send<MsgHub, TArgs> (Instance, msg, args); | |
} | |
public static void Subscribe<TArgs> (object subscriber, Action<TArgs> callback) | |
{ | |
var msg = typeof(TArgs).Name; | |
MessagingCenter.Subscribe<MsgHub, TArgs> (subscriber, msg, (s, a) => callback(a), Instance); | |
} | |
public static void Unsubscribe<TArgs> (object subscriber) | |
{ | |
var msg = typeof(TArgs).Name; | |
MessagingCenter.Unsubscribe<MsgHub, TArgs> (subscriber, msg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment