Hey all. Got a question about structuring (I'm re-...
# tornadofx
s
Hey all. Got a question about structuring (I'm re-structuring my project to use dependency injection and some viewmodels and encountering some issues.. with my brain) if anyone has a moment. I have a fragment that the user can open modally, after which they can enter a new name for a
label
, and then save it. Once saved, (or I guess, "committed" via the model) the name needs to be updated in several difference places within the application. Right now how I'm doing it is when the
label
is instantiated, it is added to a map which contains the label's string name, and a random UUID (to prevent issues with two names that are the same). I then set a listener on that map everywhere I need to update the name, and when I 'save' within the renaming fragment, I update the map entry with the new string, which then sets it elsewhere in the application. I'm trying to rewrite this using a ViewModel, but am unsure if I'm on the right track (or understanding it properly). I was thinking something like this? Is this the right setup? (Have some questions in the comments in the snippet)
Do I actually need to be using a custom Scope for getting the model within the RenameFrag?
I see I can pass a scope to the constructor in the find<Fragment> function. Maybe that's the way to do it?