• you know you can also do stuff like:...

    And here it is this ... (from post #7):

    (function() {
     var _setWatch = setWatch;
     setWatch = function(cb,pin,opts) {
       return (pin instanceof Pin)
        ? _setWatch(cb,pin,opts) // Espruino built-in pin class Pin
        : pin.setWatch(cb,opts); // Portexpander pin class PXP 
     };
    }());
    

    Espruino (you?) is(are) are not so happy with it - understandably:

    Uncaught Error: Unable to assign value to non-reference Function
     at line 6 col 2
     };
     ^
    

    If require() has the same issue, could you 'fix' that too? ...I'm milling around the require() as from require.js (requireJS.org - as it works in the browser) to make AMDs available on Espruino (via communication connection). Detection of alternative implementation is by number of arguments > 1).

    If setWatch() cannot or should not be modified to become assignable, add a property to the options, add a property to the setWatch / clearWatch function that allows alternative implementations... for example:

    setWatch.altImpls = { nonPinClass_1: alternativeImplementationFunciton_1, ... }
    clearWatch.altImpls = { nonPinClass_1: alternativeImplementationFunciton_1, ... }
    
About

Avatar for allObjects @allObjects started