Repository: incubator-weex
Updated Branches:
  refs/heads/0.15-dev 1a9e53e2a -> ba53cd43d


* [doc] Update doc of timer.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ba53cd43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ba53cd43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ba53cd43

Branch: refs/heads/0.15-dev
Commit: ba53cd43d953aa6093fcf1e3313fddadf1c94359
Parents: 1a9e53e
Author: YorkShen <shenyua...@gmail.com>
Authored: Thu Jul 13 17:50:24 2017 +0800
Committer: YorkShen <shenyua...@gmail.com>
Committed: Thu Jul 13 17:50:24 2017 +0800

----------------------------------------------------------------------
 doc/source/cn/references/modules/timer.md | 47 ++++++++++++++++++++
 doc/source/references/modules/timer.md    | 59 ++++++++++++++++++++++++++
 2 files changed, 106 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ba53cd43/doc/source/cn/references/modules/timer.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/references/modules/timer.md 
b/doc/source/cn/references/modules/timer.md
new file mode 100644
index 0000000..7bc87bb
--- /dev/null
+++ b/doc/source/cn/references/modules/timer.md
@@ -0,0 +1,47 @@
+---
+title: Timer
+type: references
+version: 0.10
+---
+
+# Timer
+Weex Timer可以用来延时启动一个一次性任务或者
重复任务。Timer会尽最大努力提供精确的延时,但是延时可能并不精确,延时时间很可能会è¶
…过用户期望的时间。实际上,timer仅仅
是为了支持HTML5中的polyfill,*不建议*开发者直接使用timer.
+
+## API
+Timer中延时的单位是毫秒,且延时时间应该为一个非负的int值(int值最大为0x7FFFFF).如果延时时间为负数或è€
…零,timer会将延时时间重置为0,即将该任务马上插å…
¥ä»»åŠ¡é˜Ÿåˆ—的尾部。
+
+### setTimeout(fn, timeout)    
+`setTimeout()`会等待指定的时间,然后执行给出的函数。
+* 可以使用 
`clearTimeout()`去阻止`setTimeout()`运行如果此时对应的`setTimeout()`还没有运行的话。
+* 如果需要重复执行任务,使用`setInterval()`.
+
+#### Arguments
+* `fn` (function): 待执行的函数.
+* `timeout` (number): 执行函数前的等待时间,单位为毫秒。 
+
+#### Return value
+一个Number对象, 表示这个任务的id。把idä¼ å…
¥clearTimeout(fnId)中可以用来取消任务。   
+
+### setInterval(fn, interval)    
+`setInterval()`每隔指定的时间间隔后,会执行对应的函数。`setInterval()`不会停止,除非`clearInterval()`被调用。`setInterval()`的返回值可以用来作为`setInterval()`的参数。
+
+#### Arguments    
+* `fn` (function): 待执行的函数。
+* `interval` (number): 
这次执行函数与下一次函数之间的时间间隔,单位为毫秒。
+
+#### Return value    
+一个Number对象,代表任务序列的id。可以把这个值传å…
¥`clearInterval`中来终止重复任务的执行。 
+
+### clearTimeout(fnId)
+`clearTimeout()`可以用来提前终止`setTimeout()`启动的任务。仅
当`setTimeout()`对应的任务没有被执行时,`clearTimeout()`才可以用来终止该任务,否则`clearTimeout()`没有任何效果。
+
+#### Arguments    
+* `fnId` (number): `setTimeout()`的返回值. 
+
+### clearInterval(fnId)
+ `clearInterval()`可以用来终止 `setInterval()`启动的任务序列。
+
+#### Arguments
+* `fnId` (number): `setInterval()`的返回值
+
+[Try it](http://dotwe.org/vue/ad564965f1eac5a4bc86946ecff70a0c)

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ba53cd43/doc/source/references/modules/timer.md
----------------------------------------------------------------------
diff --git a/doc/source/references/modules/timer.md 
b/doc/source/references/modules/timer.md
new file mode 100644
index 0000000..6813d28
--- /dev/null
+++ b/doc/source/references/modules/timer.md
@@ -0,0 +1,59 @@
+---
+title: Timer
+type: references
+version: 0.10
+---
+
+# Timer
+
+Weex encapsulates a series of APIs in order to start/stop a one-time task or a 
repeated task at a fixed delay. Please note that this module don't provide an 
accuracy delay. It provides best-effort delivery, but the actual delay may 
still exceed the delay user wants if the corresponding thread is busy.
+Actually, this module is made for the polyfill of HTML5 timer APIs, developers 
**should not** use this module directly unless they know exactly what they are 
doing.    
+
+## API
+
+All timeout or interval in this module are measured in milliseconds.    
+Also, timeout and interval should be a non-negative integer(the max of integer 
is 0x7FFFFFFF). If timeout or interval is negative, then it will be reset to 
zero, e.g. the task will be put in the task queue immediately.     
+
+### setTimeout(fn, timeout)    
+
+The `setTimeout()` method calls a function after a specified number of 
milliseconds. Use the `clearTimeout()` method to prevent the function from 
running. The function is only executed once. If you need to repeat execution, 
use the `setInterval()` method.    
+
+#### Arguments
+
+- `fn` (function): The function that will be executed
+- `timeout` (number): The number of milliseconds to wait before executing the 
function    
+
+#### Return value
+
+A Number, representing the fnId value of the timer that is set. Use this value 
with the `clearTimeout()` method to cancel the timer.   
+
+### setInterval(fn, interval)    
+
+The `setInterval()` method calls a function at specified intervals (in 
milliseconds), and it will continue calling the function until 
`clearInterval()` is called. The fnId value returned by `setInterval()` is used 
as the parameter for the `clearInterval()` method.  
+
+#### Arguments    
+
+- `fn` (function): The function that will be executed
+- `interval` (number): The intervals (in milliseconds) on how often to execute 
the function
+
+#### Return value    
+
+A Number, representing the fnId value of the timer that is set. Use this value 
with the `clearInterval()` method to cancel the timer  
+
+### clearTimeout(fnId)    
+
+The `clearTimeout()` method clears a timer set with the `setTimeout()` method. 
The fnId value returned by `setTimeout()` is used as the parameter for the 
`clearTimeout()` method. If the function has not already been executed, you 
will be able to stop the execution by calling the `clearTimeout()` method, 
otherwise, this method has no influence on the task.    
+
+#### Arguments    
+
+- `fnId` (number): The fnId value of the timer returned by the `setTimeout()` 
method
+
+### clearInterval(fnId)
+
+The `clearInterval()` method clears a timer set with the `setInterval()` 
method. The fnId value returned by `setInterval()` is used as the parameter for 
the `clearInterval()` method.    
+
+#### Arguments
+
+- `fnId` (number): The fnId of the timer returned by the `setInterval()` 
method    
+
+[Try it](http://dotwe.org/vue/ad564965f1eac5a4bc86946ecff70a0c)

Reply via email to