-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
To support some more advanced frameworks in class hierarchies.
For example, something very similar to the following situation arose for a Task class in my work one day:
var Task = Class.create( {
abstractClass: true,
execute : function() {
if( this.executing ) return;
this.executing = true;
this.doExecute(); // call hook method
},
doExecute : Class.abstractMethod
} );
var RequestTask = Task.extend( {
abstractClass: true,
doExecute : function() {
var request = this.createRequest();
request.execute().then(
_.bind( this.onSuccess, this ),
_.bind( this.onError, this )
);
},
createRequest : Class.abstractMethod,
onSuccess : function() {...},
onError : function() {...}
} );In the above example, we do not want to allow doExecute() to be redefined by a subclass of RequestTask.
Only createRequest() should be implemented to create and configure a Request object that the RequestTask will execute.