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

Modify unregisterField method #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mammadbayli
Copy link

@Mammadbayli Mammadbayli commented Dec 28, 2018

When dynamically creating controls and registering them, they are not deallocated when they are unregistered, I figured the cause could probably be the fields dictionary keeping a reference to them.
Here is my snippet of code:

 merchant.visibleParams?.map { $0.associatedControl }.forEach { control in
            control.onChange = { _ in self.validate() }
            self.validator.registerField(control, rules: [RequiredRule()]) //here I register
            section.elements.append(control)
   }

When I update the UI and unregister those controls, they are not deallocated:

   node.subnodes?.filter { $0.debugName == "dynamic" }.forEach {  control in
        self.validator.unregisterField(control as! ValidatableField)
    }

@RajatJain4061
Copy link
Member

@Mammadbayli Your PR is failing 1 check. Can you merge master branch once then push again?

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

Successfully merging this pull request may close these issues.

2 participants