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

175
Vistas
How is it possible that Ember's service() function knows the key it is called at?

A question from curiosity. I analyze some Ember app for the first time and I met such a code:

export default Service.extend({
  api: service(),
  router: service(),
  flashes: service(),
  intercom: service(),
  store: service()
  // ...
})

As I can see, the service function here is clever enough to return adequate results for every key it is called at. And my question is: how is it possible? I thought that I know JavaScript, but I have no idea how it could be implemented. JavaScript functions know only their arguments and this object they are called for, don't they?

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

0

As far as I can tell from the API docs and from the source this is able to work because you're calling service() on a special type of object which has what Ember calls an 'owner'. When the service gets called it can use the objects owner to lookup the name of the property and determine the name of the service. I might be reading this wrong, I'm like 50% confident.

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