things are run twice
nkoehring opened this issue · 1 comments
nkoehring commented
Maybe I do it wrong, but as soon as dependencies are involved, things happen twice. Example:
I have a file tree including:
index.html
app.js
app/
app/module.js
In index.html
I load includejs and appjs like this:
<!-- head section -->
<script src="/lib/include.js"></script>
<script src="/app.js"></script>
And app.js
contains:
include("app", ["app.module"], function(Module) {
console.log("I will be called twice?")
})
Now everything happens twice. If I remove any dependencies, things happen only once:
include("app", function() {
console.log("I will be called once.")
})
Module
looks like:
include("app.module", function() {
// things
function Module() {
// fancy things
}
// prototype inheritance things
return Module
})
So am I doing it wrong?
nkoehring commented
I found that creating another "main" module is the problem.
app.js
should instead look like:
include(["app.module"], function(Module) {
console.log("I will only be called once, yeah!")
})