Macadamian/titanium_mobile — pull request #100 by Harutyun (2012-07-11 12:37:57+00:00)
Title: TIMOB-9875: <Implement setTimeout>

Reviewers: Davic C, David L

Change Log:
implemented following global functions:
- setTimeout
- setInterval
- clearTimeout
- clearInterval

TestCases:
- You can use following JS code to test above mentioned functionality:

var win1 = Titanium.UI.createWindow({
backgroundColor:'#F00'
});

var t = setTimeout(function(){
Ti.API.debug('Called using setTimeout');
}, 5000);

var button2 = Titanium.UI.createButton({
title: 'Timeout',
top: 200,
});

button2.addEventListener('click',function(e)
{
Titanium.API.info("You clicked the button 2");
clearInterval(t);
//make sure setTimeout is not cleared
});

var button = Titanium.UI.createButton({
title: 'Interval',
top: 10,
});

var count = 0;
var timer = setInterval(function(){
count++;
button.title = "count: " + count;
}, 5000);

button.addEventListener('click',function(e)
{
Titanium.API.info("You clicked the button");
clearInterval(timer);
});

// open window
win1.add(button2);
win1.add(button);
win1.open();