Created
May 8, 2013 14:33
-
-
Save gshackles/5540867 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
internal IList<string> OpenMessageSubscriptions = new List<string>(); | |
protected bool ShowSubViewModel<TSubViewModel, TResult>(SubViewModelBase<TResult>.ParametersBase parameters, Action<TResult> onResult) | |
where TSubViewModel : SubViewModelBase<TResult> | |
{ | |
MvxSubscriptionToken token = null; | |
token = Messenger.Subscribe<SubNavigationResultMessage<TResult>>( | |
msg => | |
{ | |
if (token != null) | |
Messenger.Unsubscribe<SubNavigationResultMessage<TResult>>(token); | |
if (!OpenMessageSubscriptions.Contains(msg.MessageId)) | |
return; | |
OpenMessageSubscriptions.Remove(msg.MessageId); | |
onResult(msg.Result); | |
}); | |
parameters.MessageId = Guid.NewGuid().ToString(); | |
OpenMessageSubscriptions.Add(parameters.MessageId); | |
return ShowViewModel<TSubViewModel>(parameters); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment