Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rescript-react-native/permissions
ReScript bindings for react-native-permissions
https://github.com/rescript-react-native/permissions
permissions react react-native rescript rescript-react rescript-react-native
Last synced: 2 months ago
JSON representation
ReScript bindings for react-native-permissions
- Host: GitHub
- URL: https://github.com/rescript-react-native/permissions
- Owner: rescript-react-native
- License: mit
- Created: 2019-11-14T10:35:21.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-05-07T06:57:10.000Z (over 1 year ago)
- Last Synced: 2024-10-11T20:38:32.143Z (3 months ago)
- Topics: permissions, react, react-native, rescript, rescript-react, rescript-react-native
- Language: ReScript
- Homepage:
- Size: 238 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `@rescript-react-native/permissions`
[![Build Status](https://github.com/rescript-react-native/permissions/workflows/Build/badge.svg)](https://github.com/rescript-react-native/permissions/actions)
[![Version](https://img.shields.io/npm/v/@rescript-react-native/permissions.svg)](https://www.npmjs.com/@rescript-react-native/permissions)
[![ReScript Forum](https://img.shields.io/discourse/posts?color=e6484f&label=ReScript%20Forum&server=https%3A%2F%2Fforum.rescript-lang.org)](https://forum.rescript-lang.org/)[ReScript](https://rescript-lang.org) bindings for
[`react-native-permissions`](https://github.com/react-native-community/react-native-permissions).Exposed as `ReactNativePermissions` module.
`@rescript-react-native/permissions` X.y.\* means it's compatible with
`react-native-permissions` X.y.\*## Installation
When
[`react-native-permissions`](https://github.com/react-native-community/react-native-permissions)
is properly installed & configured by following their installation instructions,
you can install the bindings:```console
npm install @rescript-react-native/permissions
# or
yarn add @rescript-react-native/permissions
````@rescript-react-native/permissions` should be added to `bs-dependencies` in your
`bsconfig.json`:```diff
{
//...
"bs-dependencies": [
"@rescript/react",
"rescript-react-native",
// ...
+ "@rescript-react-native/permissions"
],
//...
}
```## Usage
```rescript
open ReactNative;let requestCamera = () => {
ReactNativePermissions.(
request(
switch (Platform.os) {
| os when os === "ios" => Ios.camera
| _ => Android.camera
},
)
|> Js.Promise.then_(permissionStatus =>
switch (permissionStatus) {
| status when status === granted => Js.Promise.resolve()
| _ => Js.Promise.reject(Js.Exn.raiseError("permission error"))
}
)
)
);
};
```---
## Changelog
Check the [changelog](./CHANGELOG.md) for more informations about recent
releases.---
## Contribute
Read the
[contribution guidelines](https://github.com/rescript-react-native/.github/blob/master/CONTRIBUTING.md)
before contributing.## Code of Conduct
We want this community to be friendly and respectful to each other. Please read
[our full code of conduct](https://github.com/rescript-react-native/.github/blob/master/CODE_OF_CONDUCT.md)
so that you can understand what actions will and will not be tolerated.