npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-user-inactivity-check

v1.0.1

Published

This library helps in monitoring child components actions like Move, Drag, Press. If the user didnt perfrom any of the actions in child screens or components, It triggers an action which is passed to it.

Downloads

8

Readme

React Native User Inactivity check

react-native-user-inactivity-check library helps in monitoring child components actions like Move, Drag, Press. If the user didnt perfrom any of the actions in child screens or components, It triggers an action which is passed to it.

Setup

Installation

$ npm install react-native-user-inactivity-check --save

or

$ yarn add react-native-user-inactivity-check

Usage

  • When the component is renderd it will start listening to the actions happening in the child Screens and Components. Main difference here is with the given timeToInactivity. This library calculates the logtime (i.e Time to trigger the action if user is inactive). It checks for every interval with logtime if the current time near logtime it triggers the action and clears the timer.

  • If it register's any action it will again calculate the logtime from that insatnt and reset the timer.

  • handleAppState prop is a boolean value which will tell the librabry to consider the appState. If this value is set to "true", And if the app is moved to background then the timer is cleared and no logtime is considered. When the app comes to foreground then app again calculates the logtime and starts the timer. By default it runs the timer in background.

  • Main objectives of this package is to handle the ideal state of the app. So that we can perform an action if the app is Ideal for a particular given time.

  • The suggested approach is if you want to monitor ideal state of complete app. Then load the App as a child in UserInactivityCheck. If it's only for a particular flow then make a "Navigator" and load it as a child.

Props

Function you need to call. This function by default returns the viewport values for screen size 1280 X 800.

| Prop | Default | Type | Description | | :------------- | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------- | | timeToInactivity | 5 | number | Minutes to wait until user respond | | interval | 5 | number | Seconds for accuracy to check inactive time | | onAction | undefined | function | Action to perform if user is inactive for given time | | handleAppState | false | boolean | Disable timer if app is in background |

Example

Basic

import React, {useState} from 'react';
import {StyleSheet, View, Text, TouchableOpacity, Alert} from 'react-native';
import UserInactiveCheck from 'react-native-user-inactivity-check';

const App = () => {
  const [showContent, setShowContent] = useState(false);
  const action = () => {
    setShowContent(true);
    Alert.alert('User is not active');
  };
  let userInactiveCheckRef = React.createRef();
  const onButtonPress = () => {
    setShowContent(false);
    userInactiveCheckRef && userInactiveCheckRef.resetTimer();
  };
  return (
    <UserInactiveCheck
      timeToInactivity={5}
      interval={10}
      onAction={action}
      ref={ref => {userInactiveCheckRef = ref;}}
      handleAppState={true}>
      <View style={styles.container}>
        <View style={styles.headView}>
          <Text style={styles.heading}>User Inactivity Demo</Text>
        </View>
        <View style={styles.buttonView}>
          {showContent ? (
            <TouchableOpacity
              style={{backgroundColor: '#DDDDDD', padding: 10}}
              onPress={onButtonPress}>
              <Text style={styles.buttonText}>Reset Timer</Text>
            </TouchableOpacity>
          ) : null}
        </View>
      </View>
    </UserInactiveCheck>
  );
};

const styles = StyleSheet.create({
  heading: {
    fontSize: 40,
    marginBottom: 30,
    alignSelf: 'center',
  },
  container: {
    flex: 1,
    padding: 15,
    justifyContent: 'center',
    backgroundColor: '#9d9d9d',
  },
  headView: {flex: 1, justifyContent: 'center', alignItems: 'center'},
  buttonView: {flex: 4, alignItems: 'center', justifyContent: 'center'},
  buttonText: {fontSize: 30},
});

export default App;