Skip to content

Commit db1a7b4

Browse files
author
pioner921227
committed
updated README
1 parent 119fdfa commit db1a7b4

File tree

2 files changed

+87
-15
lines changed

2 files changed

+87
-15
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 87 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,105 @@
1-
# react-native-sync-tasks
1+
# πŸš€ SyncTasksManager (JSI)
22

3-
api sync tasks
3+
<p align="center">
4+
<img src="./assets/img.png" width="400"/>
5+
</p>
46

5-
## Installation
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.
68

7-
```sh
8-
npm install react-native-sync-tasks
9+
---
10+
11+
## βš™οΈ Features
12+
13+
- πŸ” Periodic HTTP polling with configurable interval
14+
- πŸ“‘ Callback on data reception or error
15+
- 🧡 High-performance task execution via JSI
16+
- 🧠 Centralized task management (start/stop all tasks)
17+
- βœ… Seamless integration with native modules (C++/JSI)
18+
19+
---
20+
21+
## πŸ“¦ Installation
22+
23+
> You need to properly install and link the native JSI module `SyncTasksManager` on both iOS and Android.
24+
25+
```bash
26+
# Install your native module here (replace with real package)
27+
npm install react-native-sync-tasks-manager
928
```
1029

11-
## Usage
30+
> Don’t forget to run `pod install` for iOS if using CocoaPods.
31+
32+
---
1233

34+
## πŸ› οΈ Usage
1335

14-
```js
15-
import { multiply } from 'react-native-sync-tasks';
36+
```ts
37+
import { createTask, SyncTasksManager } from 'react-native-sync-tasks-manager';
1638

17-
// ...
39+
const task = createTask<{ response: string }>({
40+
config: {
41+
url: 'https://jsonplaceholder.typicode.com/posts/1',
42+
interval: 2000,
43+
headers: {
44+
'Content-Type': 'application/json',
45+
'Accept': 'application/json',
46+
},
47+
},
48+
onData: (data) => {
49+
console.log('DATA', data);
50+
},
51+
onError: (error) => {
52+
console.log('ERROR', error);
53+
},
54+
});
1855

19-
const result = multiply(3, 7);
56+
SyncTasksManager.addTask(task);
57+
SyncTasksManager.startAll();
2058
```
2159

60+
---
2261

23-
## Contributing
62+
## πŸ” API
2463

25-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
64+
### `createTask<T>(props: TCreateTaskProps<T>): Task`
2665

27-
## License
66+
Creates a background task that will periodically fetch data from the specified URL.
2867

29-
MIT
68+
#### Props:
69+
70+
| Name | Type | Description |
71+
|-----------|----------------------------------------------------------------------|-----------------------------------------------|
72+
| `config` | `{ url: string; interval: number; headers?: Record<string, string> }` | HTTP polling configuration |
73+
| `onData` | `(data: T) => void` | Callback when data is successfully received |
74+
| `onError` | `(error: { error: string; body?: string; code: number }) => void` | Callback when request fails (optional) |
75+
76+
### `Task`
77+
78+
Represents an individual background sync task.
79+
80+
#### Methods:
81+
82+
- `start(): void` β€” Manually start the task
83+
- `stop(): void` β€” Stop the task
84+
- `isRunning(): boolean` β€” Check if the task is currently running
3085

3186
---
3287

33-
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
88+
### `SyncTasksManager`
89+
90+
A global task manager for controlling multiple tasks at once.
91+
92+
#### Methods:
93+
94+
- `addTask(task: Task): void` β€” Add a single task
95+
- `addTasks(tasks: Task[]): void` β€” Add multiple tasks
96+
- `startAll(): void` β€” Start all registered tasks
97+
- `stopAll(): void` β€” Stop all running tasks
98+
99+
---
100+
101+
## πŸ“„ License
102+
103+
MIT
104+
105+
---

β€Žassets/img.pngβ€Ž

70.5 KB
Loading

0 commit comments

Comments
Β (0)