mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
timer moved in separate module
This commit is contained in:
15
BCL.csproj
15
BCL.csproj
@ -169,14 +169,15 @@
|
|||||||
<TypeScriptCompile Include="promises\index.ts" />
|
<TypeScriptCompile Include="promises\index.ts" />
|
||||||
<TypeScriptCompile Include="http\http.ts" />
|
<TypeScriptCompile Include="http\http.ts" />
|
||||||
<TypeScriptCompile Include="ios7.d.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="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" />
|
<Content Include="_references.ts" />
|
||||||
<TypeScriptCompile Include="Console\console.d.ts" />
|
<TypeScriptCompile Include="Console\console.d.ts" />
|
||||||
<Content Include="Image\Readme.md" />
|
<Content Include="Image\Readme.md" />
|
||||||
|
@ -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
|
```js
|
||||||
require("globals");
|
require("globals");
|
||||||
|
|
||||||
setTimeout(function(){ log("Test"); }, 2000);
|
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)
|
|
||||||
```
|
```
|
@ -1,8 +1,8 @@
|
|||||||
declare var module, setTimeout, clearTimeout, setInterval, clearInterval;
|
declare var module, setTimeout, clearTimeout, setInterval, clearInterval;
|
||||||
import globals = require("globals/globals");
|
import timer = require("timer/timer");
|
||||||
module.exports = globals;
|
module.exports = timer;
|
||||||
|
|
||||||
setTimeout = globals.setTimeout;
|
setTimeout = timer.setTimeout;
|
||||||
clearTimeout = globals.clearTimeout;
|
clearTimeout = timer.clearTimeout;
|
||||||
setInterval = globals.setInterval;
|
setInterval = timer.setInterval;
|
||||||
clearInterval = globals.clearTimeout;
|
clearInterval = timer.clearTimeout;
|
16
timer/Readme.md
Normal file
16
timer/Readme.md
Normal 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
2
timer/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
declare var module, require;
|
||||||
|
module.exports = require("timer/timer");
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Android specific global functions implementation.
|
* Android specific timer functions implementation.
|
||||||
*/
|
*/
|
||||||
var timeoutHandler;
|
var timeoutHandler;
|
||||||
var timeoutCallbacks = {};
|
var timeoutCallbacks = {};
|
2
globals/globals.d.ts → timer/timer.d.ts
vendored
2
globals/globals.d.ts → timer/timer.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* global functions.
|
* Timer functions.
|
||||||
*/
|
*/
|
||||||
export declare function setTimeout(callback: Function, milliseconds: number): number;
|
export declare function setTimeout(callback: Function, milliseconds: number): number;
|
||||||
export declare function clearTimeout(id: number): void;
|
export declare function clearTimeout(id: number): void;
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* iOS specific global functions implementation.
|
* iOS specific timer functions implementation.
|
||||||
*/
|
*/
|
||||||
var timeoutCallbacks = {};
|
var timeoutCallbacks = {};
|
||||||
|
|
Reference in New Issue
Block a user