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

134
Views
¿Hay alguna manera de actualizar una variable fuera de un detector de eventos usando ese detector?

Tengo una situación en la que tengo una variable en el almacenamiento en la nube, que obtengo de forma asíncrona cada vez que quiero hacer algo con ella. Actualmente el código se ve así:

 chrome.tabs.onUpdated.addListener(function() { // Fetch example_variable from storage, then // Do things with example_variable... }); chrome.tabs.onActivated.addListener(function() { // Fetch example_variable from storage, then // Do things with example_variable... });

Dado que obtener la example_variable de ejemplo de la nube cada vez que se activan los eventos (puede ocurrir más de una docena de veces por minuto) es muy ineficiente, estaba pensando en reestructurarlo de esta manera:

 chrome.storage.onChanged.addListener(function() { // Everytime the cloud variable changes // Fetch example_variable from storage, then // set example_variable to what I fetched. }); chrome.tabs.onUpdated.addListener(function() { // Do things with example_variable... }); chrome.tabs.onActivated.addListener(function() { // Do things with example_variable... });

Mi primer pensamiento fue crear nuevos oyentes dentro del oyente de actualización de almacenamiento (y cerrar los antiguos), pero la documentación de Chrome Extension advierte directamente contra esto .

Podría usar variables de alcance global, pero eso parece increíblemente tonto y poco elegante.

¡Agradecería cualquier ayuda!

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!