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

430
Vistas
Ember Octane vs old Ember the ability of using `reopen()` method

So I working on converting a them main app.js file over to Ember 4 and native javascript. My question is how are people handling modifying things like the Route class. My current portion of codes look like this.

Route.reopen({
  //breadCrumb: null
  currentRouteModel: function () {
    return this.modelFor(this.routeName);
  }
});

I mean i guess i can rewrite the instance case of method everywhere to just do exactly what it is returning, but I wanted to see what people are doing. I also have a Component reopen on app.js that I need to fix in the migration.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

the main thing I've seen folks do is one of two things:

  • copy the code into the places that use it
  • make a class-decorator and apply that to the classes that need it

A class decorator would look something like this (and would only work in JS, and TypeScript doesn't know how "maybe"-inheritance works with class decorators (ok, it would technically "work" in TS, but you'd get type-errors)):

// usage
@withCurrentRouteModel
export default class MyRoute extends Route {}

// implementation
function withCurrentRouteModel(OriginalRoute) {
  return class extends OriginalRoute {
    @service router;

    get routeName() {
      return this.router.currentRouteName;
    }

    get currentRouteModel() {
      this.modelFor(this.routeName);
    }

  }
}

I added a usage of the RouterService

because I wasn't familiar with routeName

about 4 years ago · Juan Pablo Isaza Denunciar
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