Interaction does not return value (output) #18395
Unanswered
reelthymeos
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have an interaction that is not returning a result. I was able to get this working for a separate interaction that I defined, and can't for the life of me figure out why this one doesn't work. In my mainViewModel, I defined an interaction as such:
public Interaction<Module, ModuleDetailsViewModel> ModuleDetailsDialog { get; }
I instantiate it inside the constructor of the MainViewModel:
ModuleDetailsDialog = new Interaction<Module, ModuleDetailsViewModel>();
Now what happens in my MainViewModel is that I am subscribed to an event that passes me an object of type 'Module.' That object is ultimately what I supply to my interaction as its input. When that event fires, the below method is called in my MainViewModel:
Now, let's look at the code behind for the MainWindow (whos data context is the MainViewModel)
In the ModuleDetailsViewModel, I have a reactiveCommand that a button in the ModuleDetailsView is bound to. It simply returns itself, because I need this object back as the output of the interaction.
public ReactiveCommand<Unit, ModuleDetailsViewModel> UpdateLabels { get; }
UpdateLabels = ReactiveCommand.Create(onUpdateLabel);
But when the dialog is called in the main view module, nothing is returned, result is null.
var result = await ModuleDetailsDialog.Handle(module);
This worked for an almost completely equivalent interaction I created, except that that interaction had type 'Unit' (no input needed) as its input as such:
public Interaction<Unit, OtherViewModel> OtherDialog { get; }
in that case, when I awaited the dialog, it came back with an instance of the view model as expected (the interaction's output). Can anyone provide insight into what might be going wrong here?
Beta Was this translation helpful? Give feedback.
All reactions