Coder Social home page Coder Social logo

kosso / ti.mely Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benbahrenburg/ti.mely

4.0 2.0 0.0 33.56 MB

Ti.mely Native Timers for Titanium Mobile

License: MIT License

JavaScript 0.06% Java 96.05% Makefile 3.41% C++ 0.23% Objective-C 0.17% Python 0.08%

ti.mely's Introduction

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.

ti.mely's People

Contributors

benbahrenburg avatar kosso avatar etruta avatar sharpred avatar yuchi avatar

Stargazers

Martin avatar Leonardo Amigoni avatar Josh Lambert avatar Jason David Miller avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.