3ba2dd0d-0f00-482d-a89a-bd07ffc896a1.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. cc._RF.push(module, '3ba2d0NDwBILaiavQf/yJah', 'NotificationManager');
  3. // lightMVC/core/manager/NotificationManager.ts
  4. "use strict";
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. /**
  7. * 消息管理类
  8. */
  9. var ViewManager_1 = require("./ViewManager");
  10. var NotificationManager = /** @class */ (function () {
  11. /**
  12. * @constructor
  13. * @private
  14. */
  15. function NotificationManager() {
  16. }
  17. /**
  18. * 单例获取类
  19. */
  20. NotificationManager.getInstance = function () {
  21. return this._instance;
  22. };
  23. /**
  24. * 发送消息通知, 框架使用,外部不得调用。
  25. * @param {string} noti 通知key值
  26. * @param {Object} body 消息传递的参数
  27. * @private
  28. */
  29. NotificationManager.prototype.__sendNotification__ = function (noti, body) {
  30. // pop view
  31. var popViewList = ViewManager_1.ViewManager.getInstance().popViewList;
  32. this.loopMap(popViewList, noti, body);
  33. // add layer view
  34. var layerViewList = ViewManager_1.ViewManager.getInstance().layerViewList;
  35. this.loopMap(layerViewList, noti, body);
  36. // scene
  37. var curScene = ViewManager_1.ViewManager.getInstance().curScene;
  38. if (curScene)
  39. this.loopMap([curScene], noti, body);
  40. };
  41. /**
  42. * 循环遍历map检索通知对象
  43. * @param {BaseMediator[]} list view mediator list
  44. * @param {string} noti 消息名称
  45. * @param {Object} body 消息传递的参数
  46. */
  47. NotificationManager.prototype.loopMap = function (list, noti, body) {
  48. for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
  49. var med = list_1[_i];
  50. var notiMap = med["_notiMap"];
  51. notiMap.forEach(function (value, key) {
  52. if (key === noti) {
  53. value.cb.call(value.target, body);
  54. }
  55. }, this);
  56. }
  57. };
  58. // 实例
  59. NotificationManager._instance = new NotificationManager();
  60. return NotificationManager;
  61. }());
  62. exports.default = NotificationManager;
  63. cc._RF.pop();