Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
Close modal but let promise be resolved in Apps Script

I am using React to write code for my Apps script add-on. I want handleCancel to be executed on click of the Cancel button. It executes someAsyncMethod and then closes the modal using google.script.host.close().

export const SampleCmp = () => {
    const handleCancel = async () => {
        await someAsyncMethod();
        google.script.host.close();
    };

    return (
      <button
        onClick={handleCancel}
      >
        Cancel
      </button>
    );
};

const someAsyncMethod() = async() : Promise<SomeObject> => {
};

Problem

someAsyncMethod takes too long (~5s) to execute and I want the modal to close immediately. If I remove the await keyword then someAsyncMethod does not complete with the resolved value or gets suspended, which I suspect happens because of the google.script.host.close. Is there a way the someAsyncMethod can continue in the background but we are able to close the modal immediately? Thanks.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

AFAIK it's not possible to keep running client-side code (JavaScript) when the host (in this case the modal) is closed. You need to consider a different approach, i.e. instead of using a modal you could use a sidebar, keeping it opened until someAsyncMethod finish.

Maybe the use a Google Apps Script add-on as a whole solution is a bad idea and you will have to rethink the solution implementation i.e. web app + add-on or as web-browser extension + add-on.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda