Skip to content

Commit

Permalink
Add comments on NetInfo.js
Browse files Browse the repository at this point in the history
Summary:
Further describe the methods available on NetInfo.

Question: How do I update the docs on the website?
Closes #7375

Differential Revision: D3303300

fbshipit-source-id: 4343d490f65e4e47b93f2c98a645cb675d2cf708
  • Loading branch information
alvinthen authored and Facebook Github Bot 2 committed May 15, 2016
1 parent e34c9c4 commit 433c0e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Libraries/Network/NetInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ const _isConnectedSubscriptions = new Map();
* ```
*/
const NetInfo = {
/**
* Invokes the listener whenever network status changes.
* The listener receives one of the connectivity types listed above.
*/
addEventListener(
eventName: ChangeEventName,
handler: Function
Expand All @@ -184,6 +188,9 @@ const NetInfo = {
};
},

/**
* Removes the listener for network status changes.
*/
removeEventListener(
eventName: ChangeEventName,
handler: Function
Expand All @@ -196,10 +203,20 @@ const NetInfo = {
_subscriptions.delete(handler);
},

/**
* Returns a promise that resolves with one of the connectivity types listed
* above.
*/
fetch(): Promise {
return RCTNetInfo.getCurrentConnectivity().then(resp => resp.network_info);
},

/**
* An object with the same methods as above but the listener receives a
* boolean which represents the internet connectivity.
* Use this if you are only interested with whether the device has internet
* connectivity.
*/
isConnected: {
addEventListener(
eventName: ChangeEventName,
Expand Down

0 comments on commit 433c0e8

Please sign in to comment.