muigui 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ export default class Container extends Controller {
8
8
  addController(controller: any): any;
9
9
  pushContainer(container: any): any;
10
10
  popContainer(): this;
11
- listen(): this;
11
+ listen(listen?: boolean): this;
12
12
  #private;
13
13
  }
14
14
  import Controller from './Controller.js';
@@ -1,4 +1,4 @@
1
- /* muigui@0.0.24, license MIT */
1
+ /* muigui@0.0.25, license MIT */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -2724,6 +2724,8 @@
2724
2724
  class Container extends Controller {
2725
2725
  #controllers;
2726
2726
  #childDestController;
2727
+ #listening;
2728
+ #updateFn;
2727
2729
 
2728
2730
  constructor(className) {
2729
2731
  super(className);
@@ -2786,10 +2788,21 @@
2786
2788
  this.#childDestController = this.#childDestController.parent;
2787
2789
  return this;
2788
2790
  }
2789
- listen() {
2790
- this.#controllers.forEach(c => {
2791
- c.listen();
2792
- });
2791
+ listen(listen = true) {
2792
+ if (!this.#updateFn) {
2793
+ this.#updateFn = this.updateDisplay.bind(this);
2794
+ }
2795
+ if (listen) {
2796
+ if (!this.#listening) {
2797
+ this.#listening = true;
2798
+ addTask(this.#updateFn);
2799
+ }
2800
+ } else {
2801
+ if (this.#listening) {
2802
+ this.#listening = false;
2803
+ removeTask(this.#updateFn);
2804
+ }
2805
+ }
2793
2806
  return this;
2794
2807
  }
2795
2808
  }