Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Override of FeedPost #4

Closed
oldroy opened this Issue Aug 22, 2012 · 7 comments

Comments

Projects
None yet
2 participants

oldroy commented Aug 22, 2012

Not sure what is going on in the override file.

Why is an anonymous function being run to call Ext.override to run initComponent? Doesn't the application run the override file and get you all the way to initComponent without wrapping it up already?

Is there a better way?

Owner

lojjic commented Aug 22, 2012

That function, passed as the second argument to Ext.define(), is run after the class loader has finished loading the declared dependencies. In this case, it means that it won't attempt to override the main class until that main class is actually available. Otherwise it would throw an error.

oldroy commented Aug 22, 2012

Ok,
Gives me a clue to some other errors in another app that has some overrides. So this isn't a Architect workaround? I guess the question is, would this be done the same way without Architect?

oldroy commented Aug 22, 2012

Ah - the class isn't created until the feed is loaded.

@oldroy oldroy closed this Aug 22, 2012

Owner

lojjic commented Aug 22, 2012

This is not Architect-specific; even in manual code you'd have to make sure the target class is loaded before attempting to override it.

Note, however, that this particular syntax is only for Ext JS 4.0.

In Ext JS 4.1 and Sencha Touch, we generate an alternate syntax which basically accomplishes the same thing, but is preferred because it handles certain scenarios better as well as being a simpler syntax:

Ext.define('MyApp.view.override.MyComponent, {
    override: 'MyApp.view.MyComponent'
    initComponent: ...
});

oldroy commented Aug 22, 2012

Errrr,
So if I'm using 4.1.1 either way would work? 4.1.1 will wait to run initComponent when the class is created and available?

Owner

lojjic commented Aug 22, 2012

In 4.1 either way will probably work in most cases, but the new declarative form is preferred -- like I sad it works better in some edge cases and it's just a nicer syntax.

Note this doesn't have anything to do with running initComponent, this is only to control when it is defined. It will of course only be executed when the component is instantiated.

Refer to the API docs for a better introduction to overriding: http://docs.sencha.com/ext-js/4-1/#!/api/Ext-method-define

oldroy commented Aug 22, 2012

4.1.1 does choke on the old syntax. Not sure why. No error comments come back. I get to the point that the override is loaded and the app quits. I'll try the new syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment