rse / componentjs

ComponentJS -- Powerful run-time Component System for structuring HTML5-based Rich Clients
http://componentjs.com/
Other
85 stars 13 forks source link

When not properly unobserving there can be zombie components #20

Open Eminenz opened 11 years ago

Eminenz commented 11 years ago

Consider http://jsfiddle.net/Jwtfc/5/

We construct a component tree consisting of a super component and a sub component but forget to spool the observation in the subcomponent.

After destroying the parent component and triggering the listener of the (destroyed) subcomponent, it is confused, because its' parent component is dead. So it tries to revive it by increasing its' state in the tree.

Since we cut the link between "/" and the parent component, the parent component tries to register its' listener (again), but cannot bubble up the tree to the model, so it breaks.

I know its' intended to always have to unobserve (mostly that will be happening via unspooling), but I found it quite hard to link zombie components which cannot register listeners to a missing spool parameter when I tried to debug this bug.

My proposal would be to rather have an error message than try to increase the state of the parent component from "dead" to "created", maybe along the lines of "Triggering a listener on a dead component - did you forget an unspool?"

rse commented 11 years ago

Good catch: I'll try to let ComponentJS check for already spooled actions on state changes in the future. Remarked.