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

166
Visualizações
Ionic 2 / Angular 2 Timer

I am using an Observable timer right now to open a modal for the first 15th minute and then every 24 hours.

 presentUpgradeModel() {
    let timer = Observable.timer(900000, 86400000);
    timer.subscribe(t => {
      if (this.shouldShowUpgradeModal) {
        this.openUpgradeModel();
      }
    });

  }

I am just wondering if this is consuming too many resources in the background or if there is a better way to do this? Its a mobile app so don't want to consume a lot of background processes.

Basically I just want a modal to popup every 24 hours or so.

Would setTimeout be better for this?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Well its not only about timers its also about background app on mobiles. First of all if user close an app it will be suspended and it will not work.

If you want to have messages like that look to Push notifications.

Sure you can use plugins to prevent background sleep but then your app will be using battery.

So to sum up better use Push notifications for notify users or you can use plugin but then no matter what your app will be using batter all the time

And lastly I would use observable for timer related things

PS. I forgot about native plugin called Local Notifications. It allow you to schedule and even if app is closed it will still trigger a process. this could a way to go

over 4 years ago · Santiago Trujillo 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