The only thing I can think of off the top of my head is something like this:
var Widget = new Class({
initialize: function(arg1, arg2) {
//init code goes here
var suppressReady = arguments[2]; //hidden 3rd argument
if (!suppressReady) this.ready();
}
});
Widget.Sub = new Class({
Extends: Widge
Thanks for the brief explanation.. I can see how that could add some
overhead.
As for what I'm trying... I guess the decorator pattern would be a
good description. The initialization is a little more complicated than
that however...
What I'm looking for is a way to ensure that this one piece of
On a performance level, your initialize mutator will create a closure and
more function calls for every single class that gets initialized, not just
your desired classes. While I have in the past thought this syntax to be
elegant it can get confusing with other developers because of the 'magic'
nat
I understand that it's a "hack". I guess for my own curiosity, why is
it such a bad thing (other than it probably won't work in 2.0)? I
would think that the ability to intercept calls to functions like that
would be a good thing
On Aug 20, 3:30 pm, Aaron Newton wrote:
> To be clear, it's a h
To be clear, it's a hack. And it probably won't work in MooTools 2.0. I
probably shouldn't have mentioned it.
On Thu, Aug 20, 2009 at 3:01 PM, Jon Bomgardner wrote:
>
> That could work though it would require rewriting all of the existing
> classes
>
> Aaron, is there a reason why the approa
That could work though it would require rewriting all of the existing
classes
Aaron, is there a reason why the approach you used in the Binds
mutator wouldn't work in this case as well? perhaps something like
this:
Class.Mutators.initialize = function(initialize){
return function(){
What if you made it so your extended classes don't have an initialize
method. Create another function like 'setup', 'render' or 'init'. In your
base class in your initialize method check for this method and execute. Then
your base class has full control of the subclass execution, return state.
What I'm trying to do is automate some code that should run for EVERY
class in my class hierarchy. This code would be in the base class but
should only be called once a sub-class is fully initialized. I can't
just add it to the parent's initialize because that function could be
called at any point
There's a hack to do this (see the Class.Binds mutator). I don't recommend
using it. Class.Binds will be deprecated in MooTools 2.0, partially because
of this hack.
On Thu, Aug 20, 2009 at 1:00 PM, Rolf wrote:
>
> Not really sure if I understand what you're after exactly, but why not
> fire an e
Not really sure if I understand what you're after exactly, but why not
fire an event from one place that's picked up in the other class?
On Aug 20, 9:34 pm, jonlb wrote:
> This may sound like a stupid question but here goes anyway.
>
> Is there a way to hook into the return of the Class ini
10 matches
Mail list logo