Skip to content

kosso/ti.mely

 
 

Repository files navigation

Ti.mely

The Ti.mely project provides access to Android and iOS timers.

NB: This is a fork and a work in progress.

In order to provide parity to Javascript setTimeout and setInterval, these methods have been included for Android and iOS.

The usage is very different to the original methods in this module in that it uses a callback as the first argument, just like setInterval and setTimeout, with the interval time as the second argument.

See the updated app.js for an example.


Old methods.

// Old methods. Please see the new app.js in the examples folder.

Importing the module using require


var timerMod = require('ti.mely');

Working with the Timer Proxy

The timer proxy provides access to a native platform interval timer. A new timer is created when you call the createTimer() factory object.

Example



	var timer = timerMod.createTimer();

start

The Timer Proxy start method is called to start the timer. This method takes a dictionary with the following fields.

Parameters

interval : float

The interval in milliseconds for the timer to fire and trigger the EventListener.

debug : Boolean

The debug flat by default is false. When set to true debug statements will be printed to the console window.

Example



	var timer = timerMod.createTimer();
	
	timer.start({
		interval:2000,
		debug:true
	});

stop

The stop method turns off the interval timer. It is important to remember that if you have a EventListener added to the module you will need to use the removeEventListener method to remove your listener before all memory can be released.

Parameters

None

Example


	
	timer.stop();

Events

onIntervalChange

This event is called after the interval timer is fired. The below shows how to add the onIntervalChange. Please note it is important to remember that if you have a EventListener added to the module you will need to use the removeEventListener method to remove your listener before all memory can be released.

Example



	var timer = require('ti.mely').createTimer();
	
	function showUpdate(d){
		var msg = "interval changed - interval set to " + d.interval + " interval count = " + d.intervalCount;
		Ti.API.info(msg);
	}
	
	timer.addEventListener('onIntervalChange',showUpdate);
	
	timer.start({
		interval:6000,
		debug:true
	});

Learn More

Examples

Please check the module's example folder or

for samples on how to use this project.

Twitter

Please consider following the @benCoding Twitter for updates and more about Titanium.

Blog

For module updates, Titanium tutorials and more please check out my blog at benCoding.Com.

Dependencies

On iOS, Ti.mely uses the [MSWeakTimer](https://github.com/mindsnacks/MSWeakTimer) project by [Javier Soto](https://github.com/mindsnacks).

License

Ti.mely is available under the MIT license.

Copyright © 2013 Benjamin Bahrenburg.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Ti.mely Native Timers for Titanium Mobile

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 96.0%
  • Makefile 3.4%
  • Other 0.6%