1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    385
    Vote Rating
    4
    gkatz is on a distinguished road

      0  

    Question time based events for sench touch app

    time based events for sench touch app


    Hi all;
    I am trying to figure out the best way for me to add scheduler like functionality (not a calendar) to an app. I am looking for a cron tab like functionality. what I need is for my app to behave as if it 'taps' to the phone's clock and, for example, send an alert to the user every hour.
    my app also uses phonegap so I guess I can send notifications through it but whats the proper way to implement the scheduler part?
    I dont mind going native (phonegap) or sencha for this task.
    all suggestions are welcomed!
    thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would create a class that uses setInterval to check every minute... If you are wanting it to be an hour since the app starts then set the start time and check to see if the difference is an hour. If you are wanting it on the hour, check to see if the time is on the hour.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    385
    Vote Rating
    4
    gkatz is on a distinguished road

      0  

    Default


    thanks!
    do you think a check every minute could have an impact on application performance and responsiveness?
    also, architecturally would this be a good place to use web workers? (i guess its not yet widely supported but just form the architecture point of view)

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by gkatz View Post
    thanks!
    do you think a check every minute could have an impact on application performance and responsiveness?
    also, architecturally would this be a good place to use web workers? (i guess its not yet widely supported but just form the architecture point of view)
    The code will likely be so small that it won't impact anything... it will just be a couple lines of code.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Location
    Denmark
    Posts
    71
    Vote Rating
    1
    hjeDK is on a distinguished road

      0  

    Default


    the setInterval method doesn't seem to appear in Sencha Touch 2.
    Where do I find an equivalent?

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    setInterval is native JavaScript so you can use it with or without sencha touch.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Location
    Denmark
    Posts
    71
    Vote Rating
    1
    hjeDK is on a distinguished road

      0  

    Default


    I'm using this setInterval() to set up periodic updates of data from a store.
    What event could I listen to in order for it to be started?
    Obviously as soon as possible. I've tried to put it in the controller launch function but that is executed before my store is ready.

    EDIT: I've discovered that setInterval() might not work as expected on Android and iPhone. That diverted me to using DelayedTask as in this thread.

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    launch method is the last method that gets fired. The store should already be created.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    Jatin Dora is on a distinguished road

      0  

    Default


    Hi,
    I want to generate a timer in decresing order that is to be shown on the view.
    I am able to generate a timer but the problem i am getting is i am getting a error msg at the console of a browser.
    TypeError: 'undefined' is not a function (evaluating 'this.delay(1000)')

    While the timer is running error msg is also running along with it.
    i have the follwing code
    var min = 59;
    var sec = 60;

    var task = Ext.create('Ext.util.DelayedTask', function() {


    console.log(arguments);
    if (sec < 1 && min > 0) {
    min--;
    sec = 60;
    }
    // if(min<1 && sec<2)
    if (min == 0 && sec == 1) {
    task.cancel();
    }
    sec--
    Ext.getCmp('minute').setHtml(min);
    Ext.getCmp('second').setHtml(sec);
    console.log('minute is' + min + 'second is' + sec);

    this.delay(1000);

    });

    task.delay(1000);

    all suggestions are welcome.
    thanks