17 lines
330 B
JavaScript
17 lines
330 B
JavaScript
|
const callbacks = [];
|
||
|
let isTriggered = false;
|
||
|
export default {
|
||
|
addCreatedListener(callback) {
|
||
|
if (isTriggered) {
|
||
|
callback();
|
||
|
}
|
||
|
else {
|
||
|
callbacks.push(callback);
|
||
|
}
|
||
|
},
|
||
|
_triggerCallback() {
|
||
|
isTriggered = true;
|
||
|
callbacks.forEach(v => v());
|
||
|
},
|
||
|
};
|