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

116
Vistas
Structuring Javascript classes for interoperation

So like wading into a beach pool and finding it has a riptide, my journey in JS programming has gotten complicated quite quickly.

I have an application I am building that has a class, cataloque.js that loads and renders data. It currently does a few things that I would rather it didn't such as put up dialogs for the user.

It is imported into a file, core.js, that handles my user interaction and building parts of the UI

I want to take those user alert functions and put them into another class but then I run into some problems. A class can't be a module (as the this. operator is set to window. in modules) so I can't import another class into catalogue.js.

I also can't seem to reference functions in the core.js file from my class.

So what is the best way to structure this so I can import multiple classes and still have some way of having them 'talk' to the core.js functions?

To help illustrate:

core.js

  • imports catalogue.js creates new class variable
  • imports dialogs.js creates new class variable

So if I have code in the cataloque class that needs to alert the user and I want to call code in the dialog class how do I mediate that communication?

So catalogue calls core which then calls dialog to show the user a dialog

Do I need to declare a namespace in core.js? Is this just a crazy way to build something in JS?

Also, I have done a lot of searches for articles in this vein but I assume that since the class structure has undergone changes recently that there are not a lot of references available via searches so any good reading suggestions would be quite helpful.

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