Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda