diff --git a/en/react-native-background-timer.md b/en/react-native-background-timer.md index 357d4180a95a5bff817c770cb3ef8e78561c5c8a..f60b24955a0bb8ad41c56a0798315f2d346b160b 100644 --- a/en/react-native-background-timer.md +++ b/en/react-native-background-timer.md @@ -1,40 +1,34 @@ -> Template version: v0.2.2 +> Template version: v0.3.0

react-native-background-timer

-

- - Supported platforms - - - License - - -

-> [!TIP] [GitHub address](https://github.com/react-native-oh-library/react-native-background-timer) +This project is based on [react-native-background-timer@2.4.1](https://github.com/ocetnik/react-native-background-timer)。 -## Installation and Usage +This third-party library has been migrated to Gitee and is now available for direct download from npm, the new package name is: `@react-native-ohos/react-native-linear-gradient`, The version correspondence details are as follows: -Find the matching version information in the release address of a third-party library: [@react-native-oh-tpl/react-native-background-timer Releases](https://github.com/react-native-oh-library/react-native-background-timer/releases).For older versions that are not published to npm, please refer to the [installation guide](/en/tgz-usage-en.md) to install the tgz package. - -Go to the project directory and execute the following instruction: +| Version | Package Name | Repository | Release | +| ------------------------- | ------------------------------------------------- | ------------------ | -------------------------- | +| <= 2.4.1-0.0.2@deprecated | @react-native-oh-tpl/react-native-background-timer | [Github(deprecated)](https://github.com/react-native-oh-library/react-native-background-timer) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-background-timer/releases) | +| > 2.4.2 | @react-native-ohos/react-native-background-timer | [Gitee](https://gitee.com/openharmony-sig/rntpc_react-native-background-timer) | [Gitee Releases](https://gitee.com/openharmony-sig/rntpc_react-native-background-timer/releases) | +## 1. Installation and Usage +Go to the project directory and execute the following instruction: #### **npm** ```bash -npm install @react-native-oh-tpl/react-native-background-timer +npm install @react-native-ohos/react-native-background-timer ``` #### **yarn** ```bash -yarn add @react-native-oh-tpl/react-native-background-timer +yarn add @react-native-ohos/react-native-background-timer ``` @@ -50,34 +44,37 @@ 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("Turn on the timer...") + setText("开启定时器...") BackgroundTimer.runBackgroundTimer(()=>{ setCount(count+=1) },parseInt(delay)) } function onPressStop(){ - setText("Turn off the timer") + setText("结束定时器") BackgroundTimer.stopBackgroundTimer() } // setTimeout function setTimeoutStart(){ - setText("Turn on the timer...") + setText("开启定时器...") let timeoutId = BackgroundTimer.setTimeout(()=>{ setCount(count+=1) },parseInt(timeoutDelay)) timeoutList.push(timeoutId) } function setTimeoutStop(){ - setText("Turn off the timer") + setText("结束定时器") if(timeoutList.length>0){ BackgroundTimer.clearTimeout(timeoutList[0]) timeoutList.shift() @@ -86,14 +83,14 @@ export function BackgroundTimerExample() { // setInterval function setIntervalStart(){ - setText("Turn on the timer...") + setText("开启定时器...") let intervalId = BackgroundTimer.setInterval(()=>{ setCount(count+=1) },parseInt(intervalDelay)) setIntervalList([...intervalList,intervalId]) } function setIntervalStop(){ - setText("Turn off the timer") + setText("结束定时器") if(intervalList.length>0){ BackgroundTimer.clearInterval(intervalList[0]) intervalList.shift() @@ -113,7 +110,7 @@ export function BackgroundTimerExample() { /> {setDelay(value)}} value={delay} /> @@ -125,7 +122,7 @@ export function BackgroundTimerExample() { /> - +