mvvmfx/src/main/java/de/saxsys/mvvmfx/internal/viewloader/ViewLoaderReflectionUtils.java
static void addSceneLifecycleHooks(ViewModel viewModel, ObservableBooleanValue viewInSceneProperty) {
        if(viewModel != null) {

            if(viewModel instanceof SceneLifecycle) {
                SceneLifecycle lifecycleViewModel = (SceneLifecycle) viewModel;

                PreventGarbageCollectionStore.getInstance().put(viewInSceneProperty);

                viewInSceneProperty.addListener((observable, oldValue, newValue) -> {
					if(newValue) {
						lifecycleViewModel.onViewAdded();
					} else {
						lifecycleViewModel.onViewRemoved();
                        PreventGarbageCollectionStore.getInstance().remove(viewInSceneProperty);
					}
				});
            }
        }
    }
static void addSceneLifecycleHooks(ViewModel viewModel, ObservableBooleanValue viewInSceneProperty) {
        if(viewModel != null) {

            if(viewModel instanceof SceneLifecycle) {
                SceneLifecycle lifecycleViewModel = (SceneLifecycle) viewModel;

                PreventGarbageCollectionStore.getInstance().put(viewInSceneProperty);

                viewInSceneProperty.addListener((observable, oldValue, newValue) -> {
					if(newValue) {
						lifecycleViewModel.onViewAdded();
					} else {
						lifecycleViewModel.onViewRemoved();
                        PreventGarbageCollectionStore.getInstance().remove(viewInSceneProperty);
					}
				});
            }
        }
    }
This method adds listeners for the {@link SceneLifecycle}.