Tuesday, 25 April 2017

Disable function in NodeJS for a while

Is there any option to disable function call for a while? for example you can call this function only once per 5 seconds.

Here is my code I would like call max once per 5 seconds:

var rest =  require.main.require('./src/Core/WebService/RESTful');

module.exports = {

  updateTimetableData: function(config) {
    var url = 'http://' + config.pttIpAddress + ':' + config.pttServerPort + '/api/';
    var requestUrl = url + 'updatetimetabledata?ipAddress=' + config.pttIpAddress + '&macAddress=' + config.pttMacAddress + '&appVersion=' + config.appVersion;
    rest.getDataFromRESTWebService(requestUrl);
  }

}

This method can be called by client rest service and from server code also.



via Marcin Gwóźdź

No comments:

Post a Comment