requirejs-intellisense
requirejs-intellisense copied to clipboard
Playing around with script load firing
Doing this as a pull request to see if @lostintangent or @orand have any ideas what I am doing wrong. This pull request does not actually work, but trying to do a different approach in my effort to understand the machinery behind intellisense.
The approach I was trying to do, to allow the autocompletion in define(), was to trigger the load event after each define() call, then explicitly require the module, since by default in requirejs 2.0, define() factory functions are not called unless there is a direct require() for the define().
So I was hoping that in each call to define(), I could do a setTimeout to allow completion of the current script, then look for at the added scripts, find the one that matches a path that was recorded via requirejs.load() and if so, trigger onScriptLoad() for that script.
The trouble seems to be that the setTimeout function tracked by loadTimeId is triggered, but there are no scripts with a script src when it fires.
I guessing there is some magic that intellisense is doing, maybe I'm triggering that loadTimeId setTimeout at the wrong time.