# rn-timer

> ## Description 通用定时器组件，子控件可以自定义，由`Timer`来控制计时器的相关功能 本组件**不提供** 任何 UI 样式，只提供定时器功能。

Latest version **0.1.5** (published 2017-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install rn-timer
pnpm add rn-timer
yarn add rn-timer
bun add rn-timer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2017-09-20 |
| First published | 2017-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Simon Wang |
| Maintainers | hypersimon |

## Links

- npm: https://www.npmjs.com/package/rn-timer
- Repository: https://github.com/react-io/rn-timer
- Homepage: https://github.com/react-io/rn-timer#readme
- Issues: https://github.com/react-io/rn-timer/issues
- npm.io page: https://npm.io/package/rn-timer

## Dependencies (1)

- [@reactivex/rxjs](https://npm.io/package/@reactivex/rxjs.md) 5.4.3

## Recent versions

- 0.1.5 (latest) — 2017-09-20
- 0.1.4 — 2017-09-20
- 0.1.3 — 2017-09-12
- 0.1.2 — 2017-09-11
- 0.1.1 — 2017-09-11
- 0.1.0 — 2017-09-08
- 0.0.17 — 2017-09-08
- 0.0.16 — 2017-09-08
- 0.0.15 — 2017-09-08
- 0.0.14 — 2017-09-08
- 0.0.13 — 2017-09-08
- 0.0.12 — 2017-09-08
- 0.0.11 — 2017-09-08
- 0.0.10 — 2017-09-08
- 0.0.9 — 2017-09-08
- … 8 more at https://npm.io/package/rn-timer/versions

## README

# rn-timer

## Description
<p>通用定时器组件，子控件可以自定义，由`Timer`来控制计时器的相关功能</p>
本组件**不提供** 任何 UI 样式，只提供定时器功能。

## Install
`$ npm install rn-timer --save`


## Props

|Props|Type|Optional|default|Description|
|:--|:--|:--|:--:|:--|
|timestamp|number|❎||未来的某个时间戳(计时结束时间戳)|
| timerStep |number|✅||时间跨度,1000则为1s|
| timerUnit |number|✅|ms|(未启用)|
| binders |object|✅||值映射对|
| timerFinishedListener |func|✅||计时器计时结束的回调|



## Usage
Class `TimerExample`

```javascript
export default class TimerExample extends Component {
  render() {
    const binder = { // 值-func 映射
      hour: (date: Date) => date.getUTCHours(),
      min: (date: Date) => date.getMinutes(),
      second: (date: Date) => date.getSeconds(),
    };

    return (
      <Timer
        timerStep={10}
        binders={binder}
        timestamp={new Date().getTime() + 50000}
        timerFinishedListener={() => {
          alert('end')
        }}>

		 // your cusotmer Timer Component
        <TimerUI/>

      </Timer>
    );
  }
}

```


class `TimerUI` (Your customer component)

```javascript
import React, {Component} from 'react';
import { StyleSheet,  Text,  View} from 'react-native';

export default class TimerUI extends Component {

  static propTypes: {
    hour: React.PropTypes.number,
    min: React.PropTypes.number,
    second: React.PropTypes.number,
  }

  render() {
    const {hour, min, second} = this.props

    return (
      <View style={{marginTop: 20, flexDirection: 'column'}}>
        <Text>
          {`hour: ${hour}`}
        </Text>
        <Text>
          {`min: ${min}`}
        </Text>
        <Text>
          {`second: ${second}`}
        </Text>
      </View>
    );
  }
}

```


![图片](https://raw.githubusercontent.com/react-io/rn-timer/master/images/example.gif)

---
_Source: https://npm.io/package/rn-timer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
