cordova-plugin-timer
Advanced tools
Comparing version
{ | ||
"name": "cordova-plugin-timer", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Cordova Native Timer Plugin", | ||
@@ -5,0 +5,0 @@ "types": "./types/index.d.ts", |
@@ -60,2 +60,5 @@ cordova-plugin-timer | ||
#### `on: (eventName: string, callback: function) => void` | ||
Syntax sugar for the event handlers (onTick, onStop, onError) | ||
eventName: `error`, `tick`, `stop` | ||
@@ -85,2 +88,3 @@ ### Methods | ||
## What's new | ||
- 1.0.0 - initial code | ||
- 1.0.0 - initial code | ||
- 1.0.1 - added common event handler |
@@ -33,2 +33,3 @@ /** | ||
this._state = NativeTimer.State.STOPPED; | ||
this.timerKey = guid(); | ||
this.onTick = function () { | ||
@@ -44,3 +45,24 @@ console.log('On timer tick'); | ||
}; | ||
this.timerKey = guid(); | ||
this.on = function (eventName, callback) { | ||
if ((typeof eventName === 'string') && (typeof callback === 'function')) { | ||
switch (eventName) { | ||
case 'tick': | ||
this.onTick = function (e) { | ||
callback(e); | ||
}; | ||
break; | ||
case 'stop': | ||
this.onStop = function (e) { | ||
callback(e); | ||
}; | ||
break; | ||
case 'error': | ||
this.onError = function (e) { | ||
callback(e); | ||
}; | ||
break; | ||
} | ||
} | ||
}; | ||
} | ||
@@ -47,0 +69,0 @@ |
Sorry, the diff of this file is not supported yet
51502
1.75%470
4.68%88
4.76%