mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 10:35:54 +00:00
[fix] NetInfo event handlers
This commit is contained in:
@@ -56,8 +56,8 @@ const NetInfo = {
|
|||||||
isConnected: {
|
isConnected: {
|
||||||
addEventListener(type: string, handler: Function): { remove: () => void } {
|
addEventListener(type: string, handler: Function): { remove: () => void } {
|
||||||
invariant(eventTypes.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', type)
|
invariant(eventTypes.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', type)
|
||||||
window.addEventListener('online', handler.bind(true), false)
|
window.addEventListener('online', handler.bind(null, true), false)
|
||||||
window.addEventListener('offline', handler.bind(false), false)
|
window.addEventListener('offline', handler.bind(null, false), false)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
remove: () => NetInfo.isConnected.removeEventListener(type, handler)
|
remove: () => NetInfo.isConnected.removeEventListener(type, handler)
|
||||||
@@ -66,8 +66,8 @@ const NetInfo = {
|
|||||||
|
|
||||||
removeEventListener(type: string, handler: Function): void {
|
removeEventListener(type: string, handler: Function): void {
|
||||||
invariant(eventTypes.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', type)
|
invariant(eventTypes.indexOf(type) !== -1, 'Trying to subscribe to unknown event: "%s"', type)
|
||||||
window.removeEventListener('online', handler.bind(true), false)
|
window.removeEventListener('online', handler.bind(null, true), false)
|
||||||
window.removeEventListener('offline', handler.bind(false), false)
|
window.removeEventListener('offline', handler.bind(null, false), false)
|
||||||
},
|
},
|
||||||
|
|
||||||
fetch(): Promise {
|
fetch(): Promise {
|
||||||
|
|||||||
Reference in New Issue
Block a user