UNPKG

minapp-fetch

Version:
79 lines (78 loc) 3.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("./utils/utils"); const constants_1 = require("./constants/constants"); const error_1 = require("./constants/error"); function fetchUnsubscribe(table, event, sid) { let { minapp } = utils_1.getBaaSF(); switch (minapp) { case constants_1.PLATFORM_NAME.ZX_ALIPAY: if (!my[`${table}_${event}_${sid || '0'}`]) return; if (!my[`${table}_${event}_${sid || '0'}`].unsubscribe) return; my[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_JD: if (!jd[`${table}_${event}_${sid || '0'}`]) return; if (!jd[`${table}_${event}_${sid || '0'}`].unsubscribe) return; jd[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_KS: if (!ks[`${table}_${event}_${sid || '0'}`]) return; if (!ks[`${table}_${event}_${sid || '0'}`].unsubscribe) return; ks[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_QQ: if (!qq[`${table}_${event}_${sid || '0'}`]) return; if (!qq[`${table}_${event}_${sid || '0'}`].unsubscribe) return; qq[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_RN: if (!global[`${table}_${event}_${sid || '0'}`]) return; if (!global[`${table}_${event}_${sid || '0'}`].unsubscribe) return; global[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_SWAN: if (!swan[`${table}_${event}_${sid || '0'}`]) return; if (!swan[`${table}_${event}_${sid || '0'}`].unsubscribe) return; swan[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_TT: if (!tt[`${table}_${event}_${sid || '0'}`]) return; if (!tt[`${table}_${event}_${sid || '0'}`].unsubscribe) return; tt[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_WEAPP: if (!wx[`${table}_${event}_${sid || '0'}`]) return; if (!wx[`${table}_${event}_${sid || '0'}`].unsubscribe) return; wx[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; case constants_1.PLATFORM_NAME.ZX_WEB: if (!window[`${table}_${event}_${sid || '0'}`]) return; if (!window[`${table}_${event}_${sid || '0'}`].unsubscribe) return; window[`${table}_${event}_${sid || '0'}`].unsubscribe(); break; default: if (constants_1.PLATFORM_ALL.indexOf(minapp) === -1) { throw new Error(`minapp.unsubscribe ${error_1.METHOD_NOT_SUPPORT}`); } } } exports.default = fetchUnsubscribe;