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

111
Views
Cómo cambiar el contexto de este objeto interior

Quiero acceder a una función que está fuera de mi objeto base, pero si consolamos.log (esto) dentro de la función loadAll, entonces dará el contexto dentro del objeto. Si consuelo. registro (esto) cualquier función normal, es decir, sin acción o getter/setters, dará el contexto de toda la clase que quiero lograr

 base = observable({ isDeleting: false, registry: observable.map(), get all() { return this.registry.values(); }, loadAll:action.bound(function () { console.log(this); this.request() }), }); request = () => { console.log('hello'); }

En el ejemplo anterior, esto generará un error porque no puede acceder a la función de solicitud, pero quiero encontrar una forma de acceder a ella.

 base = observable({ isDeleting: false, registry: observable.map(), get all() { return this.registry.values(); }, loadAll:action.bound(function () { console.log(this); this.request() }), request: () => { console.log(this) //This will give context of all the function outside object that is what I want in above example. console.log('hello'); }, });
about 4 years ago · Juan Pablo Isaza
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!