deloreanjs/delorean — pull request #28 by darcyadams (2014-09-16 15:49:05+00:00)
Title: Added isMounted check and component event cleanup

This solves 2 issues...

The first was introduced in my last PR, as you cannot `setState` on an unmounted component. I have fixed this by adding an isMounted check before calling `setState` on a store change event. This should not be a problem, as should the component mount again, `getInitialState` will take care of retrieving the latest data from the stores.

The second was an existing [issue](https://github.com/deloreanjs/delorean/issues/20) where components where not cleaning up after themselves when unmounting. Node's `eventEmitter` was complaining about a memory leak in cases where a component mounts and unmounts a number of times.