Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

55
Views
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?

9 months ago · Santiago Trujillo
1 answers
Answer question

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

9 months ago · Santiago Trujillo Report
Answer question
Find remote jobs