# @gennadysx/react-native-background-thread

> Run your code in background thread

Latest version **1.2.2** (published 2022-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gennadysx/react-native-background-thread
pnpm add @gennadysx/react-native-background-thread
yarn add @gennadysx/react-native-background-thread
bun add @gennadysx/react-native-background-thread
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2022-09-23 |
| First published | 2022-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gennady Sabirovsky |
| Maintainers | gennadysx |
| Keywords | GennadySX, react-native-background-thread, react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/@gennadysx/react-native-background-thread
- Repository: https://github.com/gennadysx/react-native-background-thread
- Homepage: https://github.com/gennadysx/react-native-background-thread#readme
- Issues: https://github.com/gennadysx/react-native-background-thread/issues
- npm.io page: https://npm.io/package/@gennadysx/react-native-background-thread

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2022-09-23
- 1.2.1 — 2022-09-23
- 1.1.3 — 2022-09-07
- 1.1.2 — 2022-09-07

## README

# @gennadysx/react-native-background-thread

This package helps in executing the javascript in a background thread. Time-consuming javascript code is shifted to a native background thread by freeing the main-UI thread, which helps in increasing the efficiency of the application.
Thread priority can be handled by passing in the appropriate flags. Currently we support three types of flag as under:

| Priority Flags      | Description | Android thread value     | IOS thread value     |
| :----:       |    :----:   |     :----: | :----: |
| MAX      | This sets the thread priority to the maximum available on the corresponding native platform.       | 10  | 1.0 |
| MIN   | This sets the thread priority to the minmimum available on the corresponding native platform.        | 1     | 0.1 |
| NORMAL   | This sets the thread priority to the default or normal on the corresponding native platform.        | 5     | 0.5 |

## Getting started

`$ yarn add @gennadysx/react-native-background-thread`

### Linking

#### iOS
	1. 	Add pod 'react-native-bg-thread', :path => '../node_modules/@gennadysx/react-native-background-thread/react-native-background-thread.podspec' to your pod file under targets
		Run following commands
	2. 	cd ios
	3. 	pod install

#### Android
	No further action needed

## Usage
#### Example 1

with `Priority` flag
```javascript
import {run, BackgroundThreadPriority} from '@gennadysx/react-native-background-thread';

      run(() => {
        // Your Javascript code here
      }, BackgroundThreadPriority.MIN); // Also you can set your priority here BackgroundThreadPriority.MAX or BackgroundThreadPriority.NORMAL

```

#### Example 2

```javascript
import BackgroundThread from '@gennadysx/react-native-background-thread';

        BackgroundThread.run(()=>{
            // Your Javascript code here
        })

```

---
_Source: https://npm.io/package/@gennadysx/react-native-background-thread · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
