Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

433
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!