/** * @typedef {Object} Pixel * @property {function} initCallback */ window.amPixelManager = { pixelStore: [], /** * @returns {void} */ init: function () { this.pixelStore.filter(pixel => !pixel.isActive).forEach(async (pixel, index) => { pixel.initCallback(); this.pixelStore[index].isActive = true; }); }, /** * @param {Pixel} pixel */ addPixel: function (pixel) { this.pixelStore.push({ ...pixel, isActive: false }); }, /** * @param {string} pixelType * @returns {Pixel[]} */ getActivePixels: function (pixelType) { return this.pixelStore.filter(pixel => pixel.pixelType === pixelType && pixel.isActive); } };