1. Home
  2. Sorce Documentation
  3. JavaScript Utils
  4. Javascript – operation Timer

Javascript – operation Timer

OperationTimer class

This is wrapper class to call functions not often then given time.

It can be useful when we connect some functions for example using OnMouseMove event, at this case when we send userMessage each time event will be triggered, all messages will be queued, and after some of multiple called application will not respond at the way we want.

sourceCode

How it works

[optimize output image]

Each line has different delay, The last position is updated the least. Example below at setDelayForFunction() block

Prepare
Html imports

import:

Functions and properties
constructor(defaultTime)

default time parameter is not mandatory if it’s not provided, the default time will be 200ms

execute(functionToExecute,parameters...)

execute a function provided at first parameter with parameters proides

Example of use
at this example function onMouseMoveNow will be called not often then 250ms

execute(functionToExecute,parameters...)

execute a function provided at first parameter with parameters proides

Example of use
at this example function onMouseMoveNow will be called not often then 250ms

setDefaultDelay(delay)

Override default delay provided as constructor parameter, useful when you want to have different times based on which protocol is currently open

setDelayForFunction(function,delay)

Set not often delay for provided function only.

Example of use
result:

[optimize output image]