Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events every 60 seconds #47

Closed
gtraxx opened this issue Jun 25, 2018 · 2 comments
Closed

Events every 60 seconds #47

gtraxx opened this issue Jun 25, 2018 · 2 comments

Comments

@gtraxx
Copy link

gtraxx commented Jun 25, 2018

Hi, I want to create a counter that every 60 seconds run an event but I have to start the counter at the click of a button.
And if in events the result is false, the counter stops
How can I proceed ?

Best Regards

@gtraxx
Copy link
Author

gtraxx commented Jun 26, 2018

`var timer = new Timer();
var timeout = setTimeout(startTimer, 3000);

    function startTimer() {
        timer.start({
            startValues: {
                minutes: 1
            }
        });
        console.log(timer.getTimeValues().toString());
        timer.addEventListener('minutesUpdated', function (e) {
            console.log(timer.getTimeValues().toString());
            test();
        });
    }

    function stopTimer() {
        clearTimeout(timeout);
        timer.stop();
        timer.addEventListener('stopped', function (e) {
            console.log(timer.getTimeValues().toString());
            console.log('stop timer');
        });
        //var timeout = setTimeout(startTimer, 3000);
    }`

@albert-gonzalez
Copy link
Owner

albert-gonzalez commented Jun 26, 2018

Hi!

I created a fiddle that does something like that you want to do:

https://jsfiddle.net/xpvt214o/303935/

When you click the button, the timer starts in second 55. 5 seconds later, when the minute counter is updated, the listener is executed and stops the timer because the test function returns true.

I hope it helps you.

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants