"use strict"; cc._RF.push(module, '3f901ous3lLPa8L+qVlaya8', 'nx.plugin.view.binder'); // Scripts/nx/plugin/nx.plugin.view.binder.js "use strict"; /******************************************************************************* * * 代理: 视图监听 * * * * 2021.12.10 ******************************************************************************/ // 功能安装 var install = function install(_inst) { // 对象非法 if (nx.dt.objEmpty(_inst)) { nx.error("[视图监听插件]安装失败,对象非法!"); return false; } // 重复安装 if (nx.dt.arrGood(_inst.lstView)) { nx.error("[视图监听插件]安装失败,重复安装!"); return false; } // 安装 _inst.lstView = []; // 视图监听 nx.dt.fnEmptyError(_inst.bindView); _inst.bindView = function (_agent, _list) { // 重复监听 var map = _inst.lstView[_agent.vid]; if (nx.dt.arrNEmpty(map)) { nx.error("[视图监听插件]重复监听:" + _agent.vid); return; } // 添加 _inst.lstView[_agent.vid] = _agent; _agent.vbind(_inst, _list); }; // 视图监听全解除 nx.dt.fnEmptyError(_inst.unbindViews); _inst.unbindViews = function () { for (var vid in _inst.lstView) { var vw = _inst.lstView[vid]; if (vw) { vw.vunbind(_inst); } } _inst.lstView = {}; }; return true; }; // 功能卸载 var uninstall = function uninstall(_inst) { // 对象非法 if (nx.dt.objEmpty(_inst)) { nx.error("[视图监听插件]安装视图插件失败,对象非法!"); return false; } // 取消监听 _inst.unbindViews(); // 卸载 delete _inst.lstView; delete _inst.bindView; delete _inst.unbindViews; return true; }; module.exports = { install: install, uninstall: uninstall }; cc._RF.pop();