Skip to content
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

DI container support for single view run configurations #56

Open
pavlus opened this issue Apr 11, 2018 · 5 comments
Open

DI container support for single view run configurations #56

pavlus opened this issue Apr 11, 2018 · 5 comments

Comments

@pavlus
Copy link

pavlus commented Apr 11, 2018

If FX.dicontainer is set only from application entry point then it's not initialized upon View launch leading to AssertionError in delegates.

It would come in handy to have an ability to configure DI container for View run configuration.

@edvin
Copy link
Owner

edvin commented Apr 12, 2018

Maybe this could be generalized by allowing you to call an arbitrary function before the View is executed? I'm not sure of the value though, as you might as well just execute an App endpoint in that case. How do you envision this?

@pavlus
Copy link
Author

pavlus commented Apr 12, 2018

As I see, in the App.kt code, there is an argument for patching primary view if it's not set, probably another argument could be added for overriding?

Right now our project is Wizard-based, so I just comment out views I'm not working on from Wizard init block and use application run configuration.

@pavlus
Copy link
Author

pavlus commented Apr 13, 2018

I meant, that another argument could be added in App class, but the launched app will be it's ancestor, not the plain App.

edvin pushed a commit to edvin/tornadofx that referenced this issue Apr 16, 2018
@edvin
Copy link
Owner

edvin commented Apr 16, 2018

I added a --di-container=classname parameter to TornadoFX. You can try it out by adding a parameter in the View run configuration. If this works as expected for you, I'll add a field to the UI of the plugin run configuration as well.

@pavlus
Copy link
Author

pavlus commented Apr 17, 2018

Well, this looks like only a partial solution, because it's not quite consistent with Spring Boot, for example, where DI container is dependant on Spring context received from SpringApplication::run which depends on application arguments and Spring beans source class[es].

A common approach with FX apps is to run Spring Boot application in javafx.application.Application::init.

I haven't had experience writing IDEA plugins yet, but I'll try adding View overriding possibility to the "App" run configuration in near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants