1
- # ` @reason -react-native/netinfo `
1
+ # ` @rescript -react-native/netinfo `
2
2
3
- [ ![ Build Status] ( https://github.com/reason -react-native/netinfo/workflows/Build/badge.svg )] ( https://github.com/reason -react-native/netinfo/actions )
4
- [ ![ Version] ( https://img.shields.io/npm/v/@reason -react-native/netinfo.svg )] ( https://www.npmjs.com/@reason -react-native/netinfo )
5
- [ ![ Chat ] ( https://img.shields.io/discord/235176658175262720.svg?logo=discord&colorb=blue )] ( https://reason-react-native.github.io/discord / )
3
+ [ ![ Build Status] ( https://github.com/rescript -react-native/netinfo/workflows/Build/badge.svg )] ( https://github.com/rescript -react-native/netinfo/actions )
4
+ [ ![ Version] ( https://img.shields.io/npm/v/@rescript -react-native/netinfo.svg )] ( https://www.npmjs.com/@rescript -react-native/netinfo )
5
+ [ ![ 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 / )
6
6
7
- [ ReScript] ( https://rescript-lang.org ) / [ Reason ] ( https://reasonml.github.io ) bindings for
7
+ [ ReScript] ( https://rescript-lang.org ) bindings for
8
8
[ ` @react-native-community/netinfo ` ] ( https://github.com/react-native-netinfo/react-native-netinfo ) .
9
9
10
10
Exposed as ` ReactNativeNetInfo ` module.
11
11
12
- ` @reason -react-native/netinfo ` X.y.\* means it's compatible with
12
+ ` @rescript -react-native/netinfo ` X.y.\* means it's compatible with
13
13
` @react-native-community/netinfo ` X.y.\*
14
14
15
15
## Installation
@@ -20,22 +20,22 @@ is properly installed & configured by following their installation instructions,
20
20
you can install the bindings:
21
21
22
22
``` console
23
- npm install @reason -react-native/netinfo
23
+ npm install @rescript -react-native/netinfo
24
24
# or
25
- yarn add @reason -react-native/netinfo
25
+ yarn add @rescript -react-native/netinfo
26
26
```
27
27
28
- ` @reason -react-native/netinfo ` should be added to ` bs-dependencies ` in your
28
+ ` @rescript -react-native/netinfo ` should be added to ` bs-dependencies ` in your
29
29
` bsconfig.json ` :
30
30
31
31
``` diff
32
32
{
33
33
//...
34
34
"bs-dependencies": [
35
- "reason- react",
36
- "reason -react-native",
35
+ "@rescript/ react",
36
+ "rescript -react-native",
37
37
// ...
38
- + "@reason -react-native/netinfo"
38
+ + "@rescript -react-native/netinfo"
39
39
],
40
40
//...
41
41
}
@@ -86,7 +86,7 @@ Cellular generation of the current network connection. Valid values are:
86
86
87
87
#### ` netInfoState `
88
88
89
- ``` reason
89
+ ``` rescript
90
90
type netInfoState = {
91
91
.
92
92
"_type": netInfoStateType,
@@ -112,7 +112,7 @@ type netInfoState = {
112
112
` details ` depends on ` _type ` given within [ ` netInfoState ` ] ( #netInfoState ) . If
113
113
` _type ` is not ` null ` or ` unknown ` , ` details ` is an object as below:
114
114
115
- ``` reason
115
+ ``` rescript
116
116
type details = {
117
117
.
118
118
"isConnectionExpensive": bool,
@@ -158,7 +158,7 @@ Note that some keys may only exist in the JS object when `_type` is `wifi` or
158
158
159
159
#### ` configure `
160
160
161
- ``` reason
161
+ ``` rescript
162
162
configure: netInfoConfiguration => unit
163
163
```
164
164
@@ -167,14 +167,14 @@ configure: netInfoConfiguration => unit
167
167
To query state of the active connection, returns ` netInfoState ` wrapped in a
168
168
` Promise ` .
169
169
170
- ``` reason
170
+ ``` rescript
171
171
fetch: unit => Js.Promise.t(netInfoState)
172
172
```
173
173
174
174
Below example demonstrates determination of the cellular connection generation,
175
175
using this method.
176
176
177
- ``` reason
177
+ ``` rescript
178
178
React.useEffect0(() => {
179
179
Js.Promise.(
180
180
ReactNativeNetInfo.fetch()
@@ -216,7 +216,7 @@ React.useEffect0(() => {
216
216
217
217
To query the connection state for a particular interface.
218
218
219
- ``` reason
219
+ ``` rescript
220
220
fetchInterface: [ | `cellular | `ethernet | `wifi] => Js.Promise.t(netInfoState)
221
221
```
222
222
@@ -227,19 +227,19 @@ To subscribe to the connection state; accepts a listener of type
227
227
The listener will be called once following subscription and each time connection
228
228
state changes.
229
229
230
- ``` reason
230
+ ``` rescript
231
231
addEventListener: (netInfoState => unit) => t
232
232
```
233
233
234
234
where
235
235
236
- ``` reason
236
+ ``` rescript
237
237
type t = unit => unit
238
238
```
239
239
240
240
Below example demonstrates subscribing to changes in connection state:
241
241
242
- ``` reason
242
+ ``` rescript
243
243
React.useEffect0(() => {
244
244
let remove =
245
245
ReactNativeNetInfo.addEventListener(w =>
@@ -277,13 +277,13 @@ React.useEffect0(() => {
277
277
278
278
This method returns a React Hook with type ` netInfoState `
279
279
280
- ``` reason
280
+ ``` rescript
281
281
useNetInfo: unit => netInfoState
282
282
```
283
283
284
284
Below example demonstrates its use within a ` Text ` component:
285
285
286
- ``` reason
286
+ ``` rescript
287
287
<Text>
288
288
(
289
289
switch (ReactNativeNetInfo.useNetInfo()##details->Js.Null.toOption) {
@@ -324,11 +324,11 @@ releases.
324
324
## Contribute
325
325
326
326
Read the
327
- [ contribution guidelines] ( https://github.com/reason -react-native/.github/blob/master/CONTRIBUTING.md )
327
+ [ contribution guidelines] ( https://github.com/rescript -react-native/.github/blob/master/CONTRIBUTING.md )
328
328
before contributing.
329
329
330
330
## Code of Conduct
331
331
332
332
We want this community to be friendly and respectful to each other. Please read
333
- [ our full code of conduct] ( https://github.com/reason -react-native/.github/blob/master/CODE_OF_CONDUCT.md )
333
+ [ our full code of conduct] ( https://github.com/rescript -react-native/.github/blob/master/CODE_OF_CONDUCT.md )
334
334
so that you can understand what actions will and will not be tolerated.
0 commit comments