@cordova-plugin-agconnect/clouddb
Version:
Cordova AGC CloudDB Plugin
38 lines (37 loc) • 1.15 kB
JavaScript
;
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomNumber = exports.asyncExec = void 0;
const cordova_1 = require("cordova");
function asyncExec(clazz, ref, args = []) {
return new Promise((resolve, reject) => {
cordova_1.exec(resolve, reject, clazz, ref, args);
});
}
exports.asyncExec = asyncExec;
function randomNumber(seed = Date.now()) {
seed ^= seed << 13;
seed ^= seed >> 17;
seed ^= seed << 5;
return seed;
}
exports.randomNumber = randomNumber;
function initEventHandler() {
if (window.AGCEvents != null)
return;
window.AGCEvents = {};
window.runAGCEvent = (eventName, data, data2) => {
if (Object.prototype.hasOwnProperty.call(window.AGCEvents, eventName)) {
if (data2)
window.AGCEvents[eventName](data, data2);
else
window.AGCEvents[eventName](data);
}
};
window.subscribeAGCEvent = (eventName, handler) => {
window.AGCEvents[eventName] = handler;
};
}
initEventHandler();