Skip to main content
1-Visitor
April 1, 2017
Question

Timer on Mashup - Timer should run based on click event (Button)

  • April 1, 2017
  • 2 replies
  • 2601 views

Hi,

Is there is any way to run timer on Mashup ? Timer should run based on button click event. Thanks in advance.

2 replies

5-Regular Member
April 3, 2017

You can achieve that by creating a Service like below in a Thing and then bind this service to "Clicked" of a button Widget in your Mashup.

===============

function sleep(time) {

  var d1 = new Date().getTime();

  var d2 = new Date().getTime();

  while (d2 < d1 + time) {

    d2 = new Date().getTime();

   }

   return;

}

//Set how long you want to set sleep in ms

sleep(1000);

===============

5-Regular Member
April 3, 2017

Hi Velkumar R​,

I suppose that you can use Autorefresh here. It can be switch on off on click event.

Please share your usecase in more detail to help me suggest more in this regard.

vr-61-VisitorAuthor
1-Visitor
April 3, 2017

Hi Ankit,

When user click start button, timer should run on mashup and when user click stop button on mashup timer should stop. (Like StopWatch)

1-Visitor
April 3, 2017

You just need to call Timer Thing EnableTimer and DisableTimer services.