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.
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.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.