xq-csg-weapp_uni-ts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3KB

  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _default = {
  7. lifetimes: {
  8. created: function () {
  9. this.nextCallback = null;
  10. },
  11. detached: function () {
  12. this.cancelNextCallback();
  13. }
  14. },
  15. methods: {
  16. safeSetData: function (t, a) {
  17. var that = this;
  18. this.pendingData = Object.assign({}, this, t);
  19. a = this.setNextCallback(a);
  20. this.setData(t, function () {
  21. that.pendingData = null;
  22. a();
  23. });
  24. },
  25. setNextCallback: function (a) {
  26. var that = this;
  27. var l = true;
  28. this.nextCallback = function (t) {
  29. if (l) {
  30. l = false;
  31. that.nextCallback = null;
  32. a.call(that, t);
  33. }
  34. };
  35. this.nextCallback.cancel = function () {
  36. l = false;
  37. };
  38. return this.nextCallback;
  39. },
  40. cancelNextCallback: function () {
  41. if (null !== this.nextCallback) {
  42. this.nextCallback.cancel();
  43. this.nextCallback = null;
  44. }
  45. }
  46. }
  47. };
  48. exports.default = _default;