diff --git a/en/react-native-background-timer.md b/en/react-native-background-timer.md index 89f77c0ca25c7bd1da43705de8453e29073e1a52..12de4f5bde4da20f60aa886302e001b283e5e782 100644 --- a/en/react-native-background-timer.md +++ b/en/react-native-background-timer.md @@ -1,6 +1,4 @@ - - -> 模板版本:v0.2.1 +> Template version: v0.2.2

react-native-background-timer

@@ -15,16 +13,15 @@

-> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-background-timer) - +> [!TIP] [GitHub address](https://github.com/react-native-oh-library/react-native-background-timer) -## 安装与使用 +## Installation and Usage -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-background-timer Releases](https://github.com/react-native-oh-library/react-native-background-timer/releases),并下载适用版本的 tgz 包。 +Find the matching version information in the release address of a third-party library and download an applicable .tgz package: [@react-native-oh-tpl/react-native-background-timer Releases](https://github.com/react-native-oh-library/react-native-background-timer/releases). -进入到工程目录并输入以下命令: +Go to the project directory and execute the following instruction: -> [!TIP] # 处替换为 tgz 包的路径 +> [!TIP] Replace the content with the path of the .tgz package at the comment sign (#). @@ -42,9 +39,9 @@ yarn add @react-native-oh-tpl/react-native-background-timer@file:# -下面的代码展示了这个库的基本使用场景: +The following code shows the basic use scenario of the repository: -> [!WARNING] 使用时 import 的库名不变。 +> [!WARNING] The name of the imported repository remains unchanged. ```js import {View, Button, StyleSheet, Text,TextInput} from 'react-native'; @@ -53,37 +50,34 @@ import BackgroundTimer from "react-native-background-timer"; export function BackgroundTimerExample() { let [count, setCount] = useState(0); let [text, setText] = useState(""); - // BackgroundTimer延时 let [delay, setDelay] = useState("1000"); - // setTimeout延时 let [timeoutDelay, setTimeoutDelay] = useState("1000"); - // setInterval延时 let [intervalDelay, setIntervalDelay] = useState("1000"); let timeoutList:number[] = [] let [intervalList, setIntervalList] = useState([]); - + // runBackgroundTimer function onPressStart(){ - setText("开启定时器...") + setText("Turn on the timer...") BackgroundTimer.runBackgroundTimer(()=>{ setCount(count+=1) },parseInt(delay)) } function onPressStop(){ - setText("结束定时器") + setText("Turn off the timer") BackgroundTimer.stopBackgroundTimer() } // setTimeout function setTimeoutStart(){ - setText("开启定时器...") + setText("Turn on the timer...") let timeoutId = BackgroundTimer.setTimeout(()=>{ setCount(count+=1) },parseInt(timeoutDelay)) timeoutList.push(timeoutId) } function setTimeoutStop(){ - setText("结束定时器") + setText("Turn off the timer") if(timeoutList.length>0){ BackgroundTimer.clearTimeout(timeoutList[0]) timeoutList.shift() @@ -92,14 +86,14 @@ export function BackgroundTimerExample() { // setInterval function setIntervalStart(){ - setText("开启定时器...") + setText("Turn on the timer...") let intervalId = BackgroundTimer.setInterval(()=>{ setCount(count+=1) },parseInt(intervalDelay)) setIntervalList([...intervalList,intervalId]) } function setIntervalStop(){ - setText("结束定时器") + setText("Turn off the timer") if(intervalList.length>0){ BackgroundTimer.clearInterval(intervalList[0]) intervalList.shift() @@ -119,7 +113,7 @@ export function BackgroundTimerExample() { /> {setDelay(value)}} value={delay} /> @@ -131,7 +125,7 @@ export function BackgroundTimerExample() { /> - +