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

224
Views
¿Cómo puedo acceder a un diccionario en su propia clase/contexto para definir un método?

Un ejemplo atenuado es esta clase, que hereda de PublishableAction (para proporcionar la función estática .viewController() así como otros métodos que se usan donde está // ... ):

 class Action extends PublishableAction { static actionSelector = { buttonCommit: Symbol() }; // This part still works as intended, accessing 'Action': static buttonSession = Action.viewController({ perform: Action.actionSelector.buttonCommit }); // ... but here's the issue: // ReferenceError: Cannot access 'Action' before initialization [Action.actionSelector.buttomCommit]() { // ... } }

Ya intenté usar [this.actionSelector.buttonCommit]() y [this.constructor.actionSelector.buttonCommit]() , ambos sin tener ningún efecto en el resultado.

¿Cómo puedo corregir el ReferenceError sin tener que mover Action.actionSelector al alcance global?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es un patrón un poco extraño lo que estás tratando de lograr. ¿Pero tal vez tener un captador de "métodos" y devolver allí todos los métodos invocables que se basan en actionSelector?

 class Action extends PublishableAction { static actionSelector = { buttonCommit: Symbol() }; // This part still works as intended, accessing 'Action': static buttonSession = Action.viewController({ perform: Action.actionSelector.buttonCommit }); get methods() { return { [Action.actionSelector.buttonCommit]: function() { //... } }; } }

De lo que puede llamar (new Action()).methods[Action.actionSelector.buttonCommit]()

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!