-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Alok30/feature_wakelock
docs: documention for wakelock
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## WakeLock Service Documentation | ||
|
||
The WakeLock service provides functionality to manage WakeLock for preventing the screen from sleeping. | ||
|
||
## Usage | ||
|
||
### 1. Apply WakeLock | ||
|
||
```js | ||
import WakeLockService from 'path/to/WakeLockService'; | ||
|
||
// Apply WakeLock | ||
WakeLockService(); | ||
``` | ||
|
||
## 2. Success: successCb callBack Fn along with success msg | ||
|
||
```js | ||
const successCb = ({ msgType, msg, data }) => { | ||
console.log(msgType); // Success | ||
console.log(msg); // WakeLock successfully applied! | ||
} | ||
|
||
WakeLockService({ successCb }); | ||
``` | ||
> [!Note] | ||
> **successCb** will get an object contains the property ```msgType```, ```msg```, ```data``` | ||
## 3. Failure: failureCb callBack Fn along with failure msg | ||
```js | ||
const failureCb = ({ msgType, msg }) => { | ||
console.log(msgType); // UN_SUPPORTED_FEATURE or ERROR | ||
console.log(msg); // Corresponding error message | ||
} | ||
|
||
WakeLockService({ failureCb }); | ||
|
||
``` | ||
|
||
## 4. Combine with Callbacks and Messages | ||
|
||
```js | ||
WakeLockService({ | ||
successCb, | ||
successMsg: "WakeLock successfully applied!", | ||
failureCb, | ||
failureMsg: { | ||
unSupported: 'Your browser does not support the WakeLock feature', | ||
error: 'Unable to apply WakeLock', | ||
} | ||
}); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters