sialcasa / mvvmFX

an Application Framework for implementing the MVVM Pattern with JavaFX
Apache License 2.0
484 stars 105 forks source link

How dispose ModelWrapper #597

Closed ghost closed 1 year ago

ghost commented 4 years ago

BeanPropertyField created listener to property. How remove this listener? Creating V and VM for forms and I want avoid keep instance of ModelWrapper in memory.

`public BeanPropertyField(SideEffect updateFunction, Function<M, T> getter,
            BiConsumer<M, T> setter, T defaultValue, Supplier<R> propertySupplier) {
        this.defaultValue = defaultValue;
        this.getter = getter;
        this.setter = setter;
        this.targetProperty = propertySupplier.get();
        this.targetProperty.addListener((observable, oldValue, newValue) -> updateFunction.call());
    }`
manuel-mauky commented 4 years ago

It isn't possible to remove this listener at the moment. Can you explain in more detail what the actual problem is here? Both the targetProperty and the updateFunction are controlled internally by the ModelWrapper so there shouldn't be a problem with references that can't be garbage collected.