Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

if not disposed then dispose in removeSubview #861

Closed
wants to merge 1 commit into from

Conversation

bharatpatil
Copy link

  • call dispose on subview only if it is not disposed.
  • this is because if subview has it's own dispose implementation and if it is disposed earlier and assigning new instance back to same subview name causes subview dispose to be called again.

e.g. scenario steps are as follows
Parent View

  • ['subViewName'] = new Sub View 1
  • cancel button in Sub View 1 disposes itself
    again
    • ['subViewName'] = new Sub View 1

So main question I've here is, each view dispose() method has a condition if disposed return. Should the inheriting views add similar condition inside their respective dispose() method as well? or should this be done in removeSubview() method?

- this is because if subview has it's own dispose implementation and  if it is disposed earlier and assigning new instance back to same subview name causes subview dispose to be called again.
@paulmillr
Copy link
Contributor

this is because if subview has it's own dispose implementation and if it is disposed earlier and assigning new instance back to same subview name causes subview dispose to be called again.

Are you overriding dispose method like that?

dispose: function() {
  if (this.disposed) return;
  // Do your stuff
  super();
}

@bharatpatil
Copy link
Author

Yes. I'm doing like this now. Should this be like that? and for every view? Let me know the correct way.

@paulmillr
Copy link
Contributor

Yes, this is a correct way. So it fails even with that if() check?

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

Successfully merging this pull request may close these issues.

2 participants