Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
How to use of an instance of a class in another class

I have three separate library :

  1. Export.js : that written all export methods
  2. HamburgerMenu.js : Export.js used here
  3. 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
    }

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda