timer moved in separate module

This commit is contained in:
Vladimir Enchev
2014-05-10 16:34:23 +03:00
parent fbdb0e5523
commit db1681a88e
8 changed files with 36 additions and 27 deletions

View File

@ -169,14 +169,15 @@
<TypeScriptCompile Include="promises\index.ts" />
<TypeScriptCompile Include="http\http.ts" />
<TypeScriptCompile Include="ios7.d.ts" />
<TypeScriptCompile Include="globals\globals.android.ts">
<DependentUpon>globals.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="globals\globals.d.ts" />
<TypeScriptCompile Include="globals\globals.ios.ts">
<DependentUpon>globals.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="globals\index.ts" />
<TypeScriptCompile Include="timer\index.ts" />
<TypeScriptCompile Include="timer\timer.android.ts">
<DependentUpon>timer.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="timer\timer.d.ts" />
<TypeScriptCompile Include="timer\timer.ios.ts">
<DependentUpon>timer.d.ts</DependentUpon>
</TypeScriptCompile>
<Content Include="_references.ts" />
<TypeScriptCompile Include="Console\console.d.ts" />
<Content Include="Image\Readme.md" />

View File

@ -1,16 +1,6 @@
Globals module for defining functions part of the global context - you need only to call *require* for this module and all globals will be registered. For example setTimeout:
Globals module for defining functions part of the global context - you need only to call *require* for this module and all globals will be registered. For example:
```js
require("globals");
setTimeout(function(){ log("Test"); }, 2000);
var id = setTimeout(function(){ log("Test"); }, 2000);
...
clearTimeout(id);
setInterval(function(){ log("Test"); }, 2000);
var intervalId = setInterval(function(){ log("Test"); }, 2000);
...
clearInterval(intervalId)
```

View File

@ -1,8 +1,8 @@
declare var module, setTimeout, clearTimeout, setInterval, clearInterval;
import globals = require("globals/globals");
module.exports = globals;
import timer = require("timer/timer");
module.exports = timer;
setTimeout = globals.setTimeout;
clearTimeout = globals.clearTimeout;
setInterval = globals.setInterval;
clearInterval = globals.clearTimeout;
setTimeout = timer.setTimeout;
clearTimeout = timer.clearTimeout;
setInterval = timer.setInterval;
clearInterval = timer.clearTimeout;

16
timer/Readme.md Normal file
View File

@ -0,0 +1,16 @@
Timer module. Functions also can be availble in the global context if you require *globals* module.
```js
require("globals");
setTimeout(function(){ log("Test"); }, 2000);
var id = setTimeout(function(){ log("Test"); }, 2000);
...
clearTimeout(id);
setInterval(function(){ log("Test"); }, 2000);
var intervalId = setInterval(function(){ log("Test"); }, 2000);
...
clearInterval(intervalId)
```

2
timer/index.ts Normal file
View File

@ -0,0 +1,2 @@
declare var module, require;
module.exports = require("timer/timer");

View File

@ -1,5 +1,5 @@
/**
* Android specific global functions implementation.
* Android specific timer functions implementation.
*/
var timeoutHandler;
var timeoutCallbacks = {};

View File

@ -1,5 +1,5 @@
/**
* global functions.
* Timer functions.
*/
export declare function setTimeout(callback: Function, milliseconds: number): number;
export declare function clearTimeout(id: number): void;

View File

@ -1,5 +1,5 @@
/**
* iOS specific global functions implementation.
* iOS specific timer functions implementation.
*/
var timeoutCallbacks = {};