Skip to content

Commit 215edc6

Browse files
author
Nishanth Bhat
committed
chore: updated README and index.d.ts
1 parent 7b69b1d commit 215edc6

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# @rn-native-utils/background-sync
1+
# @rn-native-utils/workmanager
22

33
A React Native library for performing background data syncs in Android using Android's WorkManager.
44

55
## Installation
66

77
```sh
8-
npm install @rn-native-utils/background-sync
8+
npm install @rn-native-utils/workmanager
99
```
1010

1111
or
1212

1313
```sh
14-
yarn add @rn-native-utils/background-sync
14+
yarn add @rn-native-utils/workmanager
1515
```
1616

1717
## Supported Platforms
@@ -21,8 +21,8 @@ Currently, this library only supports Android.
2121
First, import the necessary functions and types from the library:
2222

2323
```ts
24-
import { schedule, cancel, disableAppIgnoringBatteryOptimization, SchedulerTypes, WorkerPolicy, TimeUnits } from 'react-native-background-sync';
25-
import type { BackgroundSchedulerParams } from 'react-native-background-sync';
24+
import { schedule, cancel, disableAppIgnoringBatteryOptimization, SchedulerTypes, WorkerPolicy, TimeUnits } from '@rn-native-utils/workmanager';
25+
import type { BackgroundSchedulerParams } from '@rn-native-utils/workmanager';
2626
```
2727

2828
### Scheduling a Background Task

index.d.ts

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1-
export enum SchedulerTypes {
2-
periodic = 'PERIODIC',
3-
oneTime = 'ONE_TIME',
4-
}
5-
6-
export enum WorkerPolicy {
7-
KEEP = 'KEEP',
8-
REPLACE = 'REPLACE',
9-
UPDATE = 'UPDATE',
10-
}
1+
declare module '@rn-native-utils/workmanager' {
2+
export enum SchedulerTypes {
3+
periodic = 'PERIODIC',
4+
oneTime = 'ONE_TIME',
5+
}
116

12-
export enum TimeUnits {
13-
HOUR = 'HOUR',
14-
DAY = 'DAY',
15-
SECOND = 'SECOND',
16-
MINUTES = 'MINUTES',
17-
}
7+
export enum WorkerPolicy {
8+
KEEP = 'KEEP',
9+
REPLACE = 'REPLACE',
10+
UPDATE = 'UPDATE',
11+
}
1812

19-
export interface BackgroundSchedulerParams {
20-
taskKey: string;
21-
type: SchedulerTypes;
22-
maxRetryAttempts?: number;
23-
retryDelay?: number;
24-
taskTimeout?: number;
25-
allowedInForeground?: boolean;
26-
syncInterval?: number;
27-
syncIntervalType?: TimeUnits;
28-
syncFlexTime?: number;
29-
syncFlexTimeType?: TimeUnits;
30-
workerPolicy?: WorkerPolicy;
31-
extras?: Record<string, unknown>;
32-
}
13+
export enum TimeUnits {
14+
HOUR = 'HOUR',
15+
DAY = 'DAY',
16+
SECOND = 'SECOND',
17+
MINUTES = 'MINUTES',
18+
}
3319

34-
export function schedule(
35-
params: BackgroundSchedulerParams,
36-
callback: (data: string | Record<string, unknown> | boolean) => Promise<void>
37-
): Promise<boolean>;
20+
export interface BackgroundSchedulerParams {
21+
taskKey: string;
22+
type: SchedulerTypes;
23+
maxRetryAttempts?: number;
24+
retryDelay?: number;
25+
taskTimeout?: number;
26+
allowedInForeground?: boolean;
27+
syncInterval?: number;
28+
syncIntervalType?: TimeUnits;
29+
syncFlexTime?: number;
30+
syncFlexTimeType?: TimeUnits;
31+
workerPolicy?: WorkerPolicy;
32+
extras?: Record<string, unknown>;
33+
}
3834

39-
export function cancel(taskKey: string): Promise<boolean>;
35+
export function schedule(
36+
params: BackgroundSchedulerParams,
37+
callback: (
38+
data: string | Record<string, unknown> | boolean
39+
) => Promise<void>
40+
): Promise<boolean>;
4041

41-
export function disableAppIgnoringBatteryOptimization(): boolean;
42+
export function cancel(taskKey: string): Promise<boolean>;
4243

43-
export type { BackgroundSchedulerParams };
44+
export function disableAppIgnoringBatteryOptimization(): boolean;
45+
}

0 commit comments

Comments
 (0)