Skip to content

Commit a639c61

Browse files
authored
Update README.md
1 parent 2ed53ce commit a639c61

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
<img src="./assets/img.png" width="700"/>
55
</p>
66

7-
**SyncTasksManager** is a native JSI-based library for React Native that allows you to manage and execute background sync tasks (such as periodic API polling) efficiently from JavaScript, while delegating the actual execution to the native layer for better performance.
7+
**SyncTasksManager** is a native JSI-based library for React Native that allows you to manage and execute **native-threaded sync tasks** (such as periodic API polling) efficiently from JavaScript, while delegating the actual execution to the native layer for better performance.
8+
9+
> ⚠️ **Note**: This is not a background task manager — tasks do not continue running when the app is in the background or killed. The polling happens while the app is active, on a native thread, outside the JS thread.
810
911
---
1012

1113
## ⚙️ Features
1214

1315
- 🔁 Periodic HTTP polling with configurable interval
1416
- 📡 Callback on data reception or error
15-
- 🧵 High-performance task execution via JSI
17+
- 🧵 High-performance execution via native thread using JSI
1618
- 🧠 Centralized task management (start/stop all tasks)
1719
- ✅ Seamless integration with native modules (C++/JSI)
1820
- ✨ Built-in response deduplication using response body hash — avoids redundant `onData` calls if the response has not changed
@@ -44,7 +46,7 @@ const task = createTask<TData>({
4446
config: {
4547
url: 'https://jsonplaceholder.typicode.com/posts/1',
4648
// 2000ms / default 1000ms
47-
interval: 2000,
49+
interval: 2000,
4850
// headers optional
4951
headers: {
5052
'Content-Type': 'application/json',
@@ -55,7 +57,7 @@ const task = createTask<TData>({
5557
onData: (data) => {
5658
console.log('DATA', data);
5759
},
58-
// { error: string, status_code: number }
60+
// { error: string, status_code: number }
5961
onError: (error) => {
6062
console.log('ERROR', error);
6163
},
@@ -67,8 +69,7 @@ SyncTasksManager.startAll();
6769
// stop all tasks
6870
SyncTasksManager.stopAll();
6971
// or stop only 1 task
70-
task.stop()
71-
72+
task.stop();
7273
```
7374

7475
---
@@ -77,21 +78,21 @@ task.stop()
7778

7879
### `createTask<T>(props: CreateTaskParams<T>): Task`
7980

80-
Creates a background task that will periodically fetch data from the specified URL.
81+
Creates a task that will periodically fetch data from the specified URL, executed on a native thread.
8182

8283
#### Params:
8384

8485
| Name | Type | Description |
8586
|-----------|----------------------------------------------------------------------|-----------------------------------------------|
8687
| `config` | `{ url: string; interval: number; headers?: Record<string, string> }` | HTTP polling configuration |
87-
| `onData` | `(data: { body: T, status_code: number }) => void` | Callback when data is successfully received |
88-
| `onError` | `(error: { error: string; status_code: number }) => void` | Callback when request fails (optional) |
88+
| `onData` | `(data: { body: T, status_code: number }) => void` | Callback when data is successfully received |
89+
| `onError` | `(error: { error: string, status_code: number }) => void` | Callback when request fails (optional) |
8990

9091
> Under the hood, the task stores a hash of the last response body. If the newly fetched response is identical (hash matches), the `onData` callback will **not** be triggered.
9192
9293
### `Task`
9394

94-
Represents an individual background sync task.
95+
Represents an individual polling task running on a native thread.
9596

9697
#### Methods:
9798

@@ -103,7 +104,7 @@ Represents an individual background sync task.
103104

104105
### `SyncTasksManager`
105106

106-
A global task manager for controlling multiple tasks at once.
107+
A global manager to control multiple polling tasks.
107108

108109
#### Methods:
109110

@@ -120,3 +121,5 @@ MIT
120121

121122
---
122123

124+
🎉 **Enjoy using react-native-sync-tasks!** Offload polling to native threads and keep your JS thread free.
125+

0 commit comments

Comments
 (0)