{"action":"created","issue":{"url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/510","repository_url":"https://api.github.com/repos/sialcasa/mvvmFX","labels_url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/510/labels{/name}","comments_url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/510/comments","events_url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/510/events","html_url":"https://github.com/sialcasa/mvvmFX/issues/510","id":249813180,"number":510,"title":"mvvmFX with database interaction","user":{"login":"No3x","id":2690708,"avatar_url":"https://avatars1.githubusercontent.com/u/2690708?v=4","gravatar_id":"","url":"https://api.github.com/users/No3x","html_url":"https://github.com/No3x","followers_url":"https://api.github.com/users/No3x/followers","following_url":"https://api.github.com/users/No3x/following{/other_user}","gists_url":"https://api.github.com/users/No3x/gists{/gist_id}","starred_url":"https://api.github.com/users/No3x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/No3x/subscriptions","organizations_url":"https://api.github.com/users/No3x/orgs","repos_url":"https://api.github.com/users/No3x/repos","events_url":"https://api.github.com/users/No3x/events{/privacy}","received_events_url":"https://api.github.com/users/No3x/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-12T13:48:32Z","updated_at":"2017-08-15T09:07:50Z","closed_at":null,"body":"It's not really an issue but rather a question about best practice. You can't find much advice about this because it is the part where GUI becomes complex. You guys at saxsys build real world applications with this framework I guess. \r\n\r\nI try to figure out what's best practice regarding JPA/ORM/database lifecycles. Whenever the database changes you have to update the ViewModel. In the contacts example you use CDI events - whenever the database changes you fire an `contactsUpdatedEvent` to reload the GUI. Do you stick to this event based approach in real world applications or is there something better? Decision about this also influences the View/ViewModel logic. Maybe you can elaborate on this regarding clean design and your personal experience.\r\n\r\nP.S. mvvmFX is more than just a framework. It helps me to separate concerns and influences my architecture for the better."},"comment":{"url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/comments/322418657","html_url":"https://github.com/sialcasa/mvvmFX/issues/510#issuecomment-322418657","issue_url":"https://api.github.com/repos/sialcasa/mvvmFX/issues/510","id":322418657,"user":{"login":"No3x","id":2690708,"avatar_url":"https://avatars1.githubusercontent.com/u/2690708?v=4","gravatar_id":"","url":"https://api.github.com/users/No3x","html_url":"https://github.com/No3x","followers_url":"https://api.github.com/users/No3x/followers","following_url":"https://api.github.com/users/No3x/following{/other_user}","gists_url":"https://api.github.com/users/No3x/gists{/gist_id}","starred_url":"https://api.github.com/users/No3x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/No3x/subscriptions","organizations_url":"https://api.github.com/users/No3x/orgs","repos_url":"https://api.github.com/users/No3x/repos","events_url":"https://api.github.com/users/No3x/events{/privacy}","received_events_url":"https://api.github.com/users/No3x/received_events","type":"User","site_admin":false},"created_at":"2017-08-15T09:07:49Z","updated_at":"2017-08-15T09:07:49Z","body":"@lestard\r\nthanks for your explanation. To be more specific:\r\n> Whenever the database changes you have to update the ViewModel.\r\n\r\nWith this I meant `update`, `insert`, `deletes` trough the JPA Persistence Manager. No external changes or other applications sharing the same database. \r\n\r\n>2. How fine grained do you model your update events?\r\n\r\nI would go with the coarse-grained event approach until hitting performance issues.\r\n\r\n>3. Where in your application are you listening to update events? \r\n\r\nScopes are really neat for this! I have tried them out to share the \"Customer selected in X and shown in Y to edit\" between the views X and Y. Consuming change events there would be the perfect place.\r\n\r\nDo you think it is possible to avoid an event approach completely (given JPA and that the database is not shared by other applications)? So this means shifting the events to Observables (`ObservableObject`, `ObservableList` etc.)? At the moment [my models look like this](https://github.com/No3x/javafx-boilerplate-hibernate-lifecycles-1nn1/blob/651670489ed7305fbe85f416ce09d93fc99b52b4/src/main/java/sample/model/Person.java): There is a `ObservableList`/`ListProperty` for the gui to bind ListViews etc. and another list for JPA. Both need to be managed and be consistent. This is really annoying. Do you use the same approach?\r\n\r\nAt the moment I develop very simple projects to try out different architectures until I find a solid base to port this to a real application."}}
{"actor":{"display_login":"No3x"}}