b = require('b');
function fooa(){
b.foob(); // calling the function from ux works without error
}
function bara(){
console.log("bar a")
}
b.foob(); // this is what causes the error
module.exports = {
fooa: fooa,
bara: bara
}
b.js:
a = require('a');
function foob(){
a.bara(a);
}
module.exports = {
foob: foob
}
If I comment out the b.barb() in a.js, I can press the ux button and everything works fine, but if call the function directly from a.js, then I get this error:
Error: TypeError: a.bara is not a function: Name: TypeError: a.bara is not a function
Error message: Uncaught TypeError: a.bara is not a function
File name: b.js
Line number: 4
Source line: a.bara(a);
JS stack trace: TypeError: a.bara is not a function
at Object.foob (b.js:4:4)
at a.js:11:3
at Object._tempMethod (b.js:1:53)
in Fuse.Reactive.DiagnosticSubject<b.js:4>
Error: TypeError: a.bara is not a function: Name: TypeError: a.bara is not a function
Error message: Uncaught TypeError: a.bara is not a function
File name: b.js
Line number: 4
Source line: a.bara(a);
JS stack trace: TypeError: a.bara is not a function
at Object.foob (b.js:4:4)
at Object._tempMethod (a.js:11:3)
in Fuse.Reactive.DiagnosticSubject<b.js:4>
So why can I call it through ux, but not from js and how can I get it working from js?
thanks for the reply. These links helped and I splitted things up in a proper viewmodel and model structure. But the problem still exists, that I cannot re-call the functions between 2 models (non-viewmodel). In this example a.js and b.js would be models and there would actually be no viewmodel necessary for this example. But I will re-read and try to find out what I am missing. For now I solved it by outsourcing the bara function into a third model, so no model is calling itself through another model.