https://github.com/robinpowered/react-native-interaction-provider
Determines if a user is interacting with the application
https://github.com/robinpowered/react-native-interaction-provider
Last synced: about 1 year ago
JSON representation
Determines if a user is interacting with the application
- Host: GitHub
- URL: https://github.com/robinpowered/react-native-interaction-provider
- Owner: robinpowered
- Created: 2017-06-01T18:26:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-12T15:07:12.000Z (about 8 years ago)
- Last Synced: 2024-10-29T12:57:28.016Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://npm.im/react-native-interaction-provider
- Size: 17.6 KB
- Stars: 21
- Watchers: 12
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-interaction-provider
A behavioral component wrapper detecting user interactions, and letting you know when the application has idled.
## Installation
```
$ npm install react-native-interaction-provider --save
```
## Usage
```js
import InteractionProvider from 'react-native-interaction-provider'
console.log('User no longer idle')}
onInactive={() => console.log('User is idle, dismiss the screen or something')}
>
```
### Important Note
`InteractionProvider` uses the `PanResponder` to detect gestures. It will apply the `PanHandlers` to the component that it wraps. The wrapped component must apply the provided props to its root `View`.
Example:
```js
class YourScreen extends React.Component {
render() {
const {
props,
you,
care,
about,
...rest
} = this.props;
return (
...
);
}
}
```
## Roadmap
`context` support for registering specific inactivity rules and callbacks:
```js
componentDidMount() {
this.sub = this.context.interactionProvider.register(10 * 1000, this.onActive, this.onInactive)
}
componentWillUnmount() {
this.sub.remove()
}
onActive() {
console.log('user is active')
}
onInactive() {
console.log('user is inactive after 10s')
}
```