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)