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

Prevent double initialization of ViewModels which have both naming-convention and @Initialize annotated init method #604

Open
manuel-mauky opened this issue Nov 12, 2019 · 0 comments
Labels

Comments

@manuel-mauky
Copy link
Collaborator

manuel-mauky commented Nov 12, 2019

If a ViewModel has a single method with the signature of public void initialize() which is also annotated with @Initialize then this method will be invoked two times by the ViewLoader.

public class MyViewModel implements ViewModel {

	@Initialize
	public void initialize() {
		System.out.println("Will be invoked twice");
	}
}

The reason for this is that mvvmFX supports the naming convention of standard JavaFX and has also an annotation for initialization.

However, this is can lead to errors because double initialization is most likely a bug. To fix this we should invoke the initialize method only once.

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

No branches or pull requests

1 participant