react-native-pagecall
Advanced tools
Comparing version 2.0.13-nomi2 to 2.0.13-nomi3
@@ -66,3 +66,2 @@ "use strict"; | ||
var _NativeModules$Pageca3, _NativeModules$Pageca4; | ||
console.log('PagecallView is being disposed'); | ||
(_NativeModules$Pageca3 = _reactNative.NativeModules.PagecallViewManager) === null || _NativeModules$Pageca3 === void 0 ? void 0 : (_NativeModules$Pageca4 = _NativeModules$Pageca3.dispose) === null || _NativeModules$Pageca4 === void 0 ? void 0 : _NativeModules$Pageca4.call(_NativeModules$Pageca3); | ||
@@ -72,3 +71,13 @@ mountCount -= 1; | ||
}, []); | ||
const eventHandlers = { | ||
onLoad, | ||
onError, | ||
onTerminate, | ||
onMessage, | ||
onEvent | ||
}; | ||
const eventHandlersRef = (0, _react.useRef)(eventHandlers); | ||
eventHandlersRef.current = eventHandlers; | ||
const onNativeEvent = (0, _react.useCallback)(event => { | ||
const eventHandlers = eventHandlersRef.current; | ||
const data = event.nativeEvent; | ||
@@ -79,3 +88,4 @@ if (!data) return; | ||
{ | ||
onLoad === null || onLoad === void 0 ? void 0 : onLoad(); | ||
var _eventHandlers$onLoad; | ||
(_eventHandlers$onLoad = eventHandlers.onLoad) === null || _eventHandlers$onLoad === void 0 ? void 0 : _eventHandlers$onLoad.call(eventHandlers); | ||
return; | ||
@@ -85,3 +95,4 @@ } | ||
{ | ||
onError === null || onError === void 0 ? void 0 : onError(new Error(data.message)); | ||
var _eventHandlers$onErro; | ||
(_eventHandlers$onErro = eventHandlers.onError) === null || _eventHandlers$onErro === void 0 ? void 0 : _eventHandlers$onErro.call(eventHandlers, new Error(data.message)); | ||
return; | ||
@@ -91,3 +102,4 @@ } | ||
{ | ||
onTerminate === null || onTerminate === void 0 ? void 0 : onTerminate(data.reason); | ||
var _eventHandlers$onTerm; | ||
(_eventHandlers$onTerm = eventHandlers.onTerminate) === null || _eventHandlers$onTerm === void 0 ? void 0 : _eventHandlers$onTerm.call(eventHandlers, data.reason); | ||
return; | ||
@@ -97,3 +109,4 @@ } | ||
{ | ||
onMessage === null || onMessage === void 0 ? void 0 : onMessage(data.message); | ||
var _eventHandlers$onMess; | ||
(_eventHandlers$onMess = eventHandlers.onMessage) === null || _eventHandlers$onMess === void 0 ? void 0 : _eventHandlers$onMess.call(eventHandlers, data.message); | ||
return; | ||
@@ -103,6 +116,7 @@ } | ||
{ | ||
onEvent === null || onEvent === void 0 ? void 0 : onEvent(data.payload); | ||
var _eventHandlers$onEven; | ||
(_eventHandlers$onEven = eventHandlers.onEvent) === null || _eventHandlers$onEven === void 0 ? void 0 : _eventHandlers$onEven.call(eventHandlers, data.payload); | ||
} | ||
} | ||
}, [onLoad, onError, onTerminate, onMessage, onEvent]); | ||
}, []); | ||
return /*#__PURE__*/_react.default.createElement(PagecallViewView, _extends({}, props, { | ||
@@ -109,0 +123,0 @@ uri: uri, |
@@ -59,3 +59,2 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var _NativeModules$Pageca3, _NativeModules$Pageca4; | ||
console.log('PagecallView is being disposed'); | ||
(_NativeModules$Pageca3 = NativeModules.PagecallViewManager) === null || _NativeModules$Pageca3 === void 0 ? void 0 : (_NativeModules$Pageca4 = _NativeModules$Pageca3.dispose) === null || _NativeModules$Pageca4 === void 0 ? void 0 : _NativeModules$Pageca4.call(_NativeModules$Pageca3); | ||
@@ -65,3 +64,13 @@ mountCount -= 1; | ||
}, []); | ||
const eventHandlers = { | ||
onLoad, | ||
onError, | ||
onTerminate, | ||
onMessage, | ||
onEvent | ||
}; | ||
const eventHandlersRef = useRef(eventHandlers); | ||
eventHandlersRef.current = eventHandlers; | ||
const onNativeEvent = useCallback(event => { | ||
const eventHandlers = eventHandlersRef.current; | ||
const data = event.nativeEvent; | ||
@@ -72,3 +81,4 @@ if (!data) return; | ||
{ | ||
onLoad === null || onLoad === void 0 ? void 0 : onLoad(); | ||
var _eventHandlers$onLoad; | ||
(_eventHandlers$onLoad = eventHandlers.onLoad) === null || _eventHandlers$onLoad === void 0 ? void 0 : _eventHandlers$onLoad.call(eventHandlers); | ||
return; | ||
@@ -78,3 +88,4 @@ } | ||
{ | ||
onError === null || onError === void 0 ? void 0 : onError(new Error(data.message)); | ||
var _eventHandlers$onErro; | ||
(_eventHandlers$onErro = eventHandlers.onError) === null || _eventHandlers$onErro === void 0 ? void 0 : _eventHandlers$onErro.call(eventHandlers, new Error(data.message)); | ||
return; | ||
@@ -84,3 +95,4 @@ } | ||
{ | ||
onTerminate === null || onTerminate === void 0 ? void 0 : onTerminate(data.reason); | ||
var _eventHandlers$onTerm; | ||
(_eventHandlers$onTerm = eventHandlers.onTerminate) === null || _eventHandlers$onTerm === void 0 ? void 0 : _eventHandlers$onTerm.call(eventHandlers, data.reason); | ||
return; | ||
@@ -90,3 +102,4 @@ } | ||
{ | ||
onMessage === null || onMessage === void 0 ? void 0 : onMessage(data.message); | ||
var _eventHandlers$onMess; | ||
(_eventHandlers$onMess = eventHandlers.onMessage) === null || _eventHandlers$onMess === void 0 ? void 0 : _eventHandlers$onMess.call(eventHandlers, data.message); | ||
return; | ||
@@ -96,6 +109,7 @@ } | ||
{ | ||
onEvent === null || onEvent === void 0 ? void 0 : onEvent(data.payload); | ||
var _eventHandlers$onEven; | ||
(_eventHandlers$onEven = eventHandlers.onEvent) === null || _eventHandlers$onEven === void 0 ? void 0 : _eventHandlers$onEven.call(eventHandlers, data.payload); | ||
} | ||
} | ||
}, [onLoad, onError, onTerminate, onMessage, onEvent]); | ||
}, []); | ||
return /*#__PURE__*/React.createElement(PagecallViewView, _extends({}, props, { | ||
@@ -102,0 +116,0 @@ uri: uri, |
{ | ||
"name": "react-native-pagecall", | ||
"version": "2.0.13-nomi2", | ||
"version": "2.0.13-nomi3", | ||
"description": "A React Native module that provides a simple WebView component to integrate Pagecall", | ||
@@ -5,0 +5,0 @@ "main": "lib/commonjs/index", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95194
709