Skip to content

Instantly share code, notes, and snippets.

@gshackles
Created November 5, 2012 04:54
Show Gist options
  • Save gshackles/4015416 to your computer and use it in GitHub Desktop.
Save gshackles/4015416 to your computer and use it in GitHub Desktop.
protected bool RequestSubNavigate<TViewModel, TResult>(IDictionary<string, string> parameterValues, Action<TResult> onResult)
where TViewModel : SubViewModelBase<TResult>
{
parameterValues = parameterValues ?? new Dictionary<string, string>();
if (parameterValues.ContainsKey("messageId"))
throw new ArgumentException("parameterValues cannot contain an item with the key 'messageId'");
string messageId = Guid.NewGuid().ToString();
parameterValues["messageId"] = messageId;
TinyMessageSubscriptionToken token = null;
token = MessengerHub.Subscribe<SubNavigationResultMessage<TResult>>(msg =>
{
if (token != null)
MessengerHub.Unsubscribe<SubNavigationResultMessage<TResult>>(token);
onResult(msg.Result);
},
msg => msg.MessageId == messageId);
return RequestNavigate<TViewModel>(parameterValues);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment