-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example for using Dialogs with mvvmfx #171
Comments
Hi @lestard unfortunately you did not find the time to document this, so I'll just ask my question here: how would you suggest opening a I could of course move the FileChooser logic to the View but as I understood this would somehow break the MVVM pattern, doesn't it? val loadImageCommand: Command = DelegateCommand {
dirtyCheckAction {
val window: Window = ???
val image = FileChooser().apply {
title = resourceBundle.getString("load.image.filechooser.title")
}.showOpenDialog(window)
}
} |
Hi @pbauerochse, I use this with Java as follow: In the
The methods openFile, ... are just events for the
And in the Subscribing to the
Then just call the methods:
Therefore you have a clear separation between the |
Hi, Some additional clarification on how to decide which logic gets to the viewModel and which code belongs to the view: In MVVM you have two basic ideas:
Sometimes these ideas are mutually exclusive so you have to find a compromise. Also keep in mind that MVVM is heavily driven by the question of how to test things. With all this in mind we try to design the code so that as much logic as possible is put in the ViewModel and only those parts that need a UI thread (or are heavily depending on UI controls) are put in the View. |
Thank you @svedie and @lestard for the input. It was a great help. I am using the publish/subscribe machanism now (for now without Scope) and it's working like a charm. Happy new year in advance to both of you |
Create a small example that shows the proper handling of dialogs with mvvmfx.
The text was updated successfully, but these errors were encountered: