Is there a simple TornadoFX-specific way of injecting something other than a component or controller (for example, a service class)?
The docs only mention using inject()
for View
and Controller
classes.
Is it best to integrate Guice or Spring for injecting anything other than these two classes?
In TornadoFX, you'd put your business logic in either a Controller
or a ViewModel
. The TornadoFX Controller
might be a slight misnomer in that way - it is actually primarily meant for business logic, not controlling the View. A View
on the other hand, normally acts as the controller for the UI elements, connecting event handlers to actions in a Controller
.
There is normally no need to use Guice or Spring, unless you are converting an application that already utilize a dependency injection framework and you don't want to rewrite those parts.
For completeness, the guide includes information about how to integrate with 3rd party injection frameworks:
https://edvin.gitbooks.io/tornadofx-guide/content/part2/Dependency%20Injection.html