github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/stories/utils/delayed-array.js (about)

     1  import { A } from '@ember/array';
     2  import ArrayProxy from '@ember/array/proxy';
     3  import { next } from '@ember/runloop';
     4  
     5  /**
     6   * This is an array whose content is empty until the next
     7   * tick, which fixes Storybook race condition rendering
     8   * problems.
     9   */
    10  
    11  export default ArrayProxy.extend({
    12    init(array) {
    13      this.set('content', A([]));
    14      this._super(...arguments);
    15      this[Symbol.iterator] = this.content[Symbol.iterator];
    16  
    17      next(this, () => {
    18        this.set('content', A(array));
    19        this[Symbol.iterator] = this.content[Symbol.iterator];
    20      });
    21    },
    22  });