You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Just to add to this: The IDE scans your code on the right hand side for mentions of require(url) - however it isn't smart enough to dynamically load module URLs that are specified in a variable.

    Espruino itself can't easily load modules via require because an HTTP request to get them would take a certain amount of time. Instead, if you want to load the module yourself do something like:

    function loadModule(moduleName, url, callback) {
      require("http").get(url, function(res) {
        var contents = "";
        res.on('data', function(data) { contents += data; });
        res.on('close', function() {Modules.addCached(moduleName, contents); callback(); });
      });
    }
    
    loadModule("transmitClass", "http://192.168.88.117:8081/transmitClas­s.js", functtion() {
      Transmit = require("transmitClass");
    });
    
About

Avatar for Gordon @Gordon started