return remover function when adding NetInfo listener
Reviewed By: dmmiller Differential Revision: D2931623 fb-gh-sync-id: d67e986e2b4a503c0966a3f90788e207c452f216 shipit-source-id: d67e986e2b4a503c0966a3f90788e207c452f216
This commit is contained in:
parent
1beced56c8
commit
1c507e6291
|
@ -166,7 +166,7 @@ const NetInfo = {
|
|||
addEventListener(
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): void {
|
||||
): {remove: () => void} {
|
||||
const listener = RCTDeviceEventEmitter.addListener(
|
||||
DEVICE_CONNECTIVITY_EVENT,
|
||||
(appStateData) => {
|
||||
|
@ -174,6 +174,9 @@ const NetInfo = {
|
|||
}
|
||||
);
|
||||
_subscriptions.set(handler, listener);
|
||||
return {
|
||||
remove: () => NetInfo.removeEventListener(eventName, handler)
|
||||
};
|
||||
},
|
||||
|
||||
removeEventListener(
|
||||
|
@ -203,7 +206,7 @@ const NetInfo = {
|
|||
addEventListener(
|
||||
eventName: ChangeEventName,
|
||||
handler: Function
|
||||
): void {
|
||||
): {remove: () => void} {
|
||||
const listener = (connection) => {
|
||||
handler(_isConnected(connection));
|
||||
};
|
||||
|
@ -212,6 +215,9 @@ const NetInfo = {
|
|||
eventName,
|
||||
listener
|
||||
);
|
||||
return {
|
||||
remove: () => NetInfo.isConnected.removeEventListener(eventName, handler)
|
||||
};
|
||||
},
|
||||
|
||||
removeEventListener(
|
||||
|
|
Loading…
Reference in New Issue