manumaticx / Ti.DrawerLayout-Demo-Alloy-App

This has moved here:
https://github.com/manumaticx/NavigationDrawer-Demo
18 stars 9 forks source link

Bug? Destory method overriden... #3

Closed Bradleycorn closed 9 years ago

Bradleycorn commented 9 years ago

In the sample app, the controllers that get swapped in and out of the drawer's main content view declare and export a destroy method, which is recommended per this article which is also listed in a comment in the controller's code.

However, in Alloy, controllers already have a destroy() method, and per the article above, it's wise to call it from a controllers own custom cleanup method. And in my case, when switching between views, I need to call the controller's built-in destory() method, and I can't beacuse calling $.destroy() from within the controller calls the custom, overriden method that is declared in the controller file. What's worse, if you call $.destroy() from inside the declared destroy(), it (obviously) creates an infinite recursion situation which results in an app crash.

Perhaps it would be worth updating the sample app to rename the exported destroy() method in the controllers to something like "dispose" or "cleanup", so that it doesn't conflict with the built-in destory() method on alloy controllers?

Or maybe I'm way off base here. I'm the first to admit that though I've been doing titanium development for some time, I'm still fairly new to alloy (and backbone), so maybe I've got something wrong here.

manumaticx commented 9 years ago

@Bradleycorn Yes, you are totally correct! I've already experienced issues with this just didn't update this sample app yet. Thanks for the pointer. I'll rename the method to cleanup asap!