cgcardona / audiofile_sdk

The SDK bits of Audiofile
1 stars 0 forks source link

Application Controller getting created twice #1

Closed cgcardona closed 11 years ago

cgcardona commented 11 years ago

In the $.getScript() call of AFApplication.prototype.getApplicationController an instance of the Application's Controller is getting created and it's constructor is getting called. However I can't get a reference to it so I create it again right below so that I can call the Object's onAFApplicationStart() method.

This is problematic if someone wants to have code in their application's constructor. It will execute twice.

Figure out how to get a reference to the Object the first time it's created.

cgcardona commented 11 years ago

FWIW the Object appears to be getting created because of the .prototype = new Foo(); line

cgcardona commented 11 years ago

I've rewritten the code to use Object.create instead of the new constructor. This removes constructor methods completely thus resolving this issue.

https://github.com/cgcardona/audiofile_sdk/commit/9addc604ee8837898cf9bc3ac94b130671533884