Open igor-tomov opened 10 years ago
Maybe we try something like Backbone's initialize. Initialize is a noop, a function the developer can write themselves for any custom initialize functionality, and Backbone will use constructor
under the hood. So a private method paired with a public, overridable noop for the developer.
Hi,
I decide to implement my custom components behavior via
components.addType(type, def)
. In fact, as I understood, an object, which I'm passing to this method will be prototype for all components with appropriate type. But there I faced with issue of getting access to prototype methods(super), which I override in my concrete component (in my case it concerns toinitialize
method).For example, we have new component type:
and then, I want to call it within of overridden method:
Of course, JavaScript doesn't support such mechanism for inheritance, but many famous libraries such as Base2 of Dean Edwards and jQuery UI Widget factory implemented workaround for accessing to super methods. In
Component.extend()
, which is used for component inheritance, I didn't find such mechanism.Actually, I have found one way, but it looks awful:
Though, we can register callback via
components.before()
for this situation. But, I think, it's not really good idea, because this is more common approach and used for all loaded components.So. Is there some convenient way to resolve it? Sorry for my bad English :( I hope, I described it correctly.