Skip to content

Commit 4fdb4ef

Browse files
author
pioner921227
committed
updated README
1 parent 76c57ba commit 4fdb4ef

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,42 @@ npm install react-native-sync-tasks
3333
```ts
3434
import { createTask, SyncTasksManager } from 'react-native-sync-tasks';
3535

36-
const task = createTask<{ response: string }>({
36+
type TData = {
37+
userId: number;
38+
id: number;
39+
title: string;
40+
body: string;
41+
};
42+
43+
const task = createTask<TData>({
3744
config: {
3845
url: 'https://jsonplaceholder.typicode.com/posts/1',
39-
interval: 2000,
46+
// 2000ms / default 1000ms
47+
interval: 2000,
48+
// headers optional
4049
headers: {
4150
'Content-Type': 'application/json',
4251
'Accept': 'application/json',
4352
},
4453
},
54+
// { body: TData, status_code: number }
4555
onData: (data) => {
4656
console.log('DATA', data);
4757
},
58+
// { error: string, status_code: number }
4859
onError: (error) => {
4960
console.log('ERROR', error);
5061
},
5162
});
5263

5364
SyncTasksManager.addTask(task);
5465
SyncTasksManager.startAll();
66+
...
67+
// stop all tasks
68+
SyncTasksManager.stopAll();
69+
// or stop only 1 task
70+
task.stop()
71+
5572
```
5673

5774
---

0 commit comments

Comments
 (0)