https://github.com/sleeplessbyte/react-native-use-idle-once
Hook to execute a callback once, once the system is idle.
https://github.com/sleeplessbyte/react-native-use-idle-once
Last synced: 3 months ago
JSON representation
Hook to execute a callback once, once the system is idle.
- Host: GitHub
- URL: https://github.com/sleeplessbyte/react-native-use-idle-once
- Owner: SleeplessByte
- License: mit
- Created: 2020-05-31T01:42:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T04:42:13.000Z (over 2 years ago)
- Last Synced: 2024-10-18T19:47:30.325Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.02 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-use-idle-once
Hook to report once interactions have ran (idle) or to run a callback once interactions have ran (idle).
## Installation
```shell
yarn install react-native-use-idle-once
```## Usage
Re-render once, once it's idle.
```typescript
/**
* Uses the interaction manager to force a re-render of components that include
* this hook, for example to start new interactions. Only reports once.
*/
import { useIdleOnce } from 'react-native-use-idle-once'
```Call a callback once, once it's idle.
```typescript
/**
* Uses the interaction manager to run the callback once the interactions have
* finished running; automatically cancelled if the component this hook is used
* in un-mounts before that.
*
* Re-runs for each callback, so make sure the callback passed in has a stable
* identity, unless you want it to run perpetually.
*
* @param callback the callback to run after interactions
*/
import { useIdleCallbackOnce } from 'react-native-use-idle-once'
```