edvin
10/28/2016, 5:24 PMComponent
you could now do val jProInstance = (scope as JProScope).instanceId
if you for some reason need to get to the instance id. You could also make a field for the primaryStage and add a method to the scope to retrieve the WebAPI. As I mentioned earlier you could even add a ViewModel in there if you create a limited scope for example to support MDI. @carlw I would love it if you would try this to see if we can support your use case with it. Will polish a bit more and then push it I think. I have tried all my apps (not scope-aware) and had no issues after the rewrite.carlw
10/28/2016, 5:26 PMedvin
10/28/2016, 5:27 PMcarlw
10/28/2016, 5:29 PMedvin
10/28/2016, 5:29 PMedvin
10/28/2016, 5:31 PMfind<ThatView>(Scope())
where scope could just be an instance of Scope
like I did here, or a custom version with the ViewModel inside. We might need to add some convenience functions to get to that viewmodel from inside the View/Fragment/Controller though.edvin
10/28/2016, 5:33 PMval myController: Controller by inject(DefaultScope)
edvin
10/28/2016, 5:35 PMinject
is now defined like this:edvin
10/28/2016, 5:35 PMedvin
10/28/2016, 5:35 PMedvin
10/28/2016, 5:36 PMedvin
10/28/2016, 5:38 PMApp
class also have a scope
variable. This should be set in init
or in start()
if you override that, but before super.start()
is called.edvin
10/28/2016, 5:38 PMedvin
10/28/2016, 5:39 PMedvin
10/28/2016, 5:42 PMfeature/scope
branch if anybody wants to play with it: https://github.com/edvin/tornadofx/tree/feature/scopecarlw
10/28/2016, 5:50 PMcarlw
10/28/2016, 5:51 PMcarlw
10/28/2016, 5:51 PMcarlw
10/28/2016, 5:52 PMedvin
10/28/2016, 5:58 PMclass.newInstance()
so it will "always just work". inject()
is actually lazy, so it will be pulled in whenever it's needed. This makes it super easy to support circular dependencies, so I've been very happy with it.edvin
10/28/2016, 5:59 PMfind
inside Component
. I had to put some more methods in there that I frankly don't want to have inside Component
so I'll be working on removing them during the weekend.edvin
10/28/2016, 6:03 PMfind
inside component just calls the find(class, scope)
function with the scope from the component.carlw
10/28/2016, 7:22 PMcarlw
10/28/2016, 7:23 PMedvin
10/28/2016, 7:26 PMclass A : Controller()
. Component doesn't have an equals/hashCode implementation.edvin
10/28/2016, 7:26 PMcarlw
10/28/2016, 7:26 PMedvin
10/28/2016, 7:29 PMComponent
is not a singleton. It's like Fragment
in that regards, so you'd get a new instance every time.edvin
10/28/2016, 7:29 PMController
inside of A
, they would be the same instance. That's a better test as well.carlw
10/28/2016, 7:30 PM