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

How to unmount a root component? #36

Closed
michael opened this issue Sep 11, 2015 · 10 comments
Closed

How to unmount a root component? #36

michael opened this issue Sep 11, 2015 · 10 comments
Assignees
Milestone

Comments

@michael
Copy link
Member

michael commented Sep 11, 2015

Once mounted injected, we have no way unmount a root component, or am I missing something?

@michael michael added this to the Beta 2 milestone Sep 11, 2015
@obuchtala
Copy link
Member

Does component.unmount() not work?

@michael
Copy link
Member Author

michael commented Sep 11, 2015

Just found it. I want to test deregistration of event handlers.

@michael
Copy link
Member Author

michael commented Sep 11, 2015

Which seems not to be done in that case. In _updateElement there's the only place:

    if (!_.isEqual(oldData.handlers, data.handlers)) {
      _.each(oldData.handlers, function(handler, event) {
        $el.off(event);
      });
      _.each(data.handlers, function(handler, event) {
        $el.on(event, handler.bind(scope.owner));
      }, this);
    }

@obuchtala
Copy link
Member

Well, this seems to be a bug.

@obuchtala
Copy link
Member

On a second thought: I don't think it is necessary to unbind the event handlers. They are part of the rendered element. It should not matter if they are still there after unmount. I would leave them.

@michael
Copy link
Member Author

michael commented Sep 11, 2015

But wouldn't this prevent the component from being garbage collected if there's a handler from that component bound to the element that could potentially survive... I'm not sure i understand this completely. I mean why it does not matter to not call .off().

@obuchtala
Copy link
Member

No. Why would it. Both, the component and the element are having the same life-time.

@obuchtala
Copy link
Member

Why should the element survive?

@michael
Copy link
Member Author

michael commented Sep 11, 2015

Mhh.. probably true yes.. and if i keep a reference to the unmounted component or el, it's the user's fault.

@obuchtala
Copy link
Member

I think so.

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

No branches or pull requests

2 participants