timermodule v0.0.6
USAGE
Import it as
import Timer from "timermodule";
Create an instance for it and initialize it (using init method) before using the methods of the instance.
let timerObj = new Timer();
timerObj.init(initializationData);
The above initialization data object is of the pattern:
"data" : {
"mytimer(yourtimername)" : {
time : {
hh : "00",
mm : "00",
ss : "00
},
status : "INIT"
}
},
"notifier" : "notifierFunction"
If many timers are required, give each timer a unique key and add the data in the above format.
The notifier function will be called each time for a change in timer object. The notifier function will get an arguement in the format : (key, value). The value will be in the format as below :
"time"(keyword) : {
hh(keyword) : "<values>",
mm(keyword) : "<values>",
ss(keyword) : "<values>"
},
"status"(keyword) : "INIT (OR) RUNNING (OR) PAUSED"
Once you are done with creating an instance and initializing it, you can proceed calling the methods available on the timer instance
The main action methods available in timer object instance are as follows :
start, pause, resume, reset.
You have call the above functions with the name of your timer as arguement. Eg : start("mytimer")
.
To update the timer abruptly, you can use updateTimerState
method.
Eg : updateTimerState(<nameoftimer>, <actionname>, <durationinhh,mm,ssobformat))
;
i.e nameoftimer - In the above example - "mytimer". actionname - supported values are : START, RESUME, PAUSE, RESET durationinhh,mm,ssobformat - time object in the format { hh , mm, ss}
Examples available in : CodeSandbox example link