import { useMainStore } from '@/store';

export default {
    // Adds event to the bus given its category, subcategory, and eventValue;
    addEventToBus(category, subCategory, eventValue) {
        useMainStore().addEventToBus({
            category,
            subCategory,
            eventValue
        });
    },

    // Finds event on the bus, removes the item, and returns its value to the caller.
    readAndPopEventFromBus(category, subCategory) {
        const event = useMainStore().eventBusItem(category, subCategory);

        if (event) {
            useMainStore().removeEventFromBus({
                category,
                subCategory
            });
        }

        return event;
    },

    // Finds the event on the bus and returns its value to the caller, does not remove it.
    readEventFromBus(category, subCategory) {
        const event = useMainStore().eventBusItem(category, subCategory);

        return event;
    }
};
