open-nomad/ui/stories/utils/delayed-array.js

23 lines
567 B
JavaScript

import { A } from '@ember/array';
import ArrayProxy from '@ember/array/proxy';
import { next } from '@ember/runloop';
/**
* This is an array whose content is empty until the next
* tick, which fixes Storybook race condition rendering
* problems.
*/
export default ArrayProxy.extend({
init(array) {
this.set('content', A([]));
this._super(...arguments);
this[Symbol.iterator] = this.content[Symbol.iterator];
next(this, () => {
this.set('content', A(array));
this[Symbol.iterator] = this.content[Symbol.iterator];
});
},
});