I'm a big fan of mapped callback functions in JS, to the extent that I'm
actively trying not to become a crank on the subject.

Still, coming from Java, if I'm going to have to do without type-safety,
and most early error detection, and the sort of optimising compilation
that probably does exactly this sort of mapping for big if/else's, I
want to make full use of functions as first-class objects and a decent
object field look-up speed.

So the short answer is:  I'm on it.  I implemented it one way
(attributeSet would automatically look for a setter method on the peer),
but on reflexion I think looking for a method on the bridge would be
better---for one thing, a bridge's schema then immediately gets
reflected in its setters and its superclass':


FryerWidgetBridge
===================
allowed attributes: width, height, x, y, temperature, crispiness
method[s] implemented in class:  setCrispinessAttribute
method[s] implemented in abstract superclass CookerToolkitBridge: 
 
setWidthAttribute,...setXAttribute,...,setTemperatureAtrribute


This is a convention-dependent mechanism, but it should be easy to
short-circuit it for
any bridge for which we want to do something special:

PlotBridge.prototype.attributeSet = function(attributeChangeEvent){
        // If it's a special event, do something special....
        if( event.getName() == "stooge" && event.getValue()="Pinky"){
                this.setTakeOverTarget("The World") ;
        } else {
                // otherwise, fall back on the conventional method
implemented 
                // in AbstractBlackBoxWidgetBridge:
        
xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.attributeSet.ca
ll(this,event) ;
      }
}

Reply via email to