From db1681a88e4264c32fb7ce69c083ddd1e0670de7 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Sat, 10 May 2014 16:34:23 +0300 Subject: [PATCH] timer moved in separate module --- BCL.csproj | 15 ++++++++------- globals/Readme.md | 12 +----------- globals/index.ts | 12 ++++++------ timer/Readme.md | 16 ++++++++++++++++ timer/index.ts | 2 ++ .../globals.android.ts => timer/timer.android.ts | 2 +- globals/globals.d.ts => timer/timer.d.ts | 2 +- globals/globals.ios.ts => timer/timer.ios.ts | 2 +- 8 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 timer/Readme.md create mode 100644 timer/index.ts rename globals/globals.android.ts => timer/timer.android.ts (96%) rename globals/globals.d.ts => timer/timer.d.ts (75%) rename globals/globals.ios.ts => timer/timer.ios.ts (95%) diff --git a/BCL.csproj b/BCL.csproj index 1cd2e7421..b84d0656c 100644 --- a/BCL.csproj +++ b/BCL.csproj @@ -169,14 +169,15 @@ - - globals.d.ts - - - - globals.d.ts - + + + timer.d.ts + + + + timer.d.ts + diff --git a/globals/Readme.md b/globals/Readme.md index 8b6f5299f..aef82f8ec 100644 --- a/globals/Readme.md +++ b/globals/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 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) ``` \ No newline at end of file diff --git a/globals/index.ts b/globals/index.ts index 0178cdb2c..5e78e0ee6 100644 --- a/globals/index.ts +++ b/globals/index.ts @@ -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; \ No newline at end of file +setTimeout = timer.setTimeout; +clearTimeout = timer.clearTimeout; +setInterval = timer.setInterval; +clearInterval = timer.clearTimeout; \ No newline at end of file diff --git a/timer/Readme.md b/timer/Readme.md new file mode 100644 index 000000000..e3364367f --- /dev/null +++ b/timer/Readme.md @@ -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) +``` \ No newline at end of file diff --git a/timer/index.ts b/timer/index.ts new file mode 100644 index 000000000..9ffc7c961 --- /dev/null +++ b/timer/index.ts @@ -0,0 +1,2 @@ +declare var module, require; +module.exports = require("timer/timer"); \ No newline at end of file diff --git a/globals/globals.android.ts b/timer/timer.android.ts similarity index 96% rename from globals/globals.android.ts rename to timer/timer.android.ts index 9718717cc..8c8ad66ce 100644 --- a/globals/globals.android.ts +++ b/timer/timer.android.ts @@ -1,5 +1,5 @@ /** - * Android specific global functions implementation. + * Android specific timer functions implementation. */ var timeoutHandler; var timeoutCallbacks = {}; diff --git a/globals/globals.d.ts b/timer/timer.d.ts similarity index 75% rename from globals/globals.d.ts rename to timer/timer.d.ts index 604d705a6..c5500fbb1 100644 --- a/globals/globals.d.ts +++ b/timer/timer.d.ts @@ -1,5 +1,5 @@ /** - * global functions. + * Timer functions. */ export declare function setTimeout(callback: Function, milliseconds: number): number; export declare function clearTimeout(id: number): void; diff --git a/globals/globals.ios.ts b/timer/timer.ios.ts similarity index 95% rename from globals/globals.ios.ts rename to timer/timer.ios.ts index a601e123b..8e1167ae4 100644 --- a/globals/globals.ios.ts +++ b/timer/timer.ios.ts @@ -1,5 +1,5 @@ /** - * iOS specific global functions implementation. + * iOS specific timer functions implementation. */ var timeoutCallbacks = {};