I have three separate library :
- Export.js : that written all export methods
- HamburgerMenu.js : Export.js used here
- Loding.js : display spiner to prepare export file
Created an instance of Export.js
in HamburgerMenu.js
then a method of instance passed through Loading.js
to run method. But there is an error in Loding.js
that can not access to editor
in Export.js
.
Export.js
and Loading.js
hasn't direct relation.
How can i solve it?
Export.js
class Export {
constructor(editor) {
this.editor = editor;
}
exportGeometry() {
var object = this.editor.selected; // return error : editor is undefined
...
}
}
HamburgerMenu.js
import { Export } from './Export';
import { Loading } from './loading';
function HamburgerMenu(editor) {
var exportModule = new Export(editor);
var loading = new Loading('Please Wait..', 'Preparing to download ...',
exportModule.exportGeometry);
}
Loading
class Loading {
constructor(title, message, Fun) {
this.title = title;
this.message = message;
Fun(); // Fun here is exportGeometry that passed from HamburgerMenu
}