UNPKG

@d4l/react-native-wear-connectivity

Version:
42 lines (41 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sendMessage = exports.sendGenuineMessage = void 0; var _reactNative = require("react-native"); var _index = require("./index"); var _constants = require("./constants"); const UNHANDLED_CALLBACK = 'The sendMessage function was called without a callback function. '; const UNHANDLED_CALLBACK_REPLY = 'The callback function was invoked with the payload: '; const UNHANDLED_CALLBACK_ERROR = 'The callback function was invoked with the error: '; const defaultReplyCb = reply => { console.log(UNHANDLED_CALLBACK + UNHANDLED_CALLBACK_REPLY, reply); }; const defaultErrCb = err => { console.warn(UNHANDLED_CALLBACK + UNHANDLED_CALLBACK_ERROR, err); }; const sendMessage = (message, cb, errCb) => { const json = { ...message, event: 'message' }; const callbackWithDefault = cb ?? defaultReplyCb; const errCbWithDefault = errCb ?? defaultErrCb; return _index.WearConnectivity.sendMessage(json, callbackWithDefault, errCbWithDefault); }; const sendGenuineMessage = (message, cb, errCb) => { const callbackWithDefault = cb ?? defaultReplyCb; const errCbWithDefault = errCb ?? defaultErrCb; return _index.WearConnectivity.sendGenuineMessage(message, callbackWithDefault, errCbWithDefault); }; const sendMessageMock = () => console.warn(_constants.LIBRARY_NAME + 'message' + _constants.IOS_NOT_SUPPORTED_WARNING); let sendMessageExport = exports.sendMessage = sendMessageMock; if (_reactNative.Platform.OS !== 'ios') { exports.sendMessage = sendMessageExport = sendMessage; } let sendGenuineMessageExport = exports.sendGenuineMessage = sendMessageMock; if (_reactNative.Platform.OS !== 'ios') { exports.sendGenuineMessage = sendGenuineMessageExport = sendGenuineMessage; } //# sourceMappingURL=messages.js.map