@d4l/react-native-wear-connectivity
Version:
Establish a two-way connection with wearOS
44 lines (43 loc) • 2.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getReachableNodes = exports.getNonCapableAndReachableNodes = exports.getCapableAndReachableNodes = void 0;
var _reactNative = require("react-native");
var _index = require("./index");
var _constants = require("./constants");
const UNHANDLED_CALLBACK = 'The capability function was called without a callback function. ';
const UNHANDLED_CALLBACK_REPLY = 'The callback function was invoked with the capability: ';
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 getReachableNodes = (cb, errCb) => {
const callbackWithDefault = cb ?? defaultReplyCb;
const errCbWithDefault = errCb ?? defaultErrCb;
return _index.WearConnectivity.getReachableNodes(callbackWithDefault, errCbWithDefault);
};
const getCapableAndReachableNodes = (capability, cb, errCb) => {
const callbackWithDefault = cb ?? defaultReplyCb;
const errCbWithDefault = errCb ?? defaultErrCb;
return _index.WearConnectivity.getCapableAndReachableNodes(capability, callbackWithDefault, errCbWithDefault);
};
const getNonCapableAndReachableNodes = (capability, cb, errCb) => {
const callbackWithDefault = cb ?? defaultReplyCb;
const errCbWithDefault = errCb ?? defaultErrCb;
return _index.WearConnectivity.getNonCapableAndReachableNodes(capability, callbackWithDefault, errCbWithDefault);
};
const nodesMock = () => console.warn(_constants.LIBRARY_NAME + 'nodes' + _constants.IOS_NOT_SUPPORTED_WARNING);
const nodesWithCapabilityMock = () => console.warn(_constants.LIBRARY_NAME + 'capability' + _constants.IOS_NOT_SUPPORTED_WARNING);
let getReachableNodesExport = exports.getReachableNodes = nodesMock;
let getCapableAndReachableNodesExport = exports.getCapableAndReachableNodes = nodesWithCapabilityMock;
let getNonCapableAndReachableNodesExport = exports.getNonCapableAndReachableNodes = nodesWithCapabilityMock;
if (_reactNative.Platform.OS !== 'ios') {
exports.getReachableNodes = getReachableNodesExport = getReachableNodes;
exports.getCapableAndReachableNodes = getCapableAndReachableNodesExport = getCapableAndReachableNodes;
exports.getNonCapableAndReachableNodes = getNonCapableAndReachableNodesExport = getNonCapableAndReachableNodes;
}
//# sourceMappingURL=capability.js.map