diff --git a/src/helpers/event-bus/event-bus.js b/src/helpers/event-bus/event-bus.js index 6987f6880..6ca248d19 100644 --- a/src/helpers/event-bus/event-bus.js +++ b/src/helpers/event-bus/event-bus.js @@ -15,6 +15,7 @@ export default { readAndPopEventFromBus(category, subCategory) { // Match our item and find the index const matchedEvent = store.state.applicationUser.eventBus.find(({ category, subCategory }) => category === category && subCategory === subCategory); + const itemIndex = store.state.applicationUser.eventBus.indexOf(matchedEvent); // If the item exists, remove it. @@ -22,13 +23,14 @@ export default { store.state.applicationUser.eventBus.splice(itemIndex, 1); } - return matchedEvent.eventValue; + return matchedEvent === undefined ? undefined : matchedEvent.eventValue; }, // Finds the event on the bus and returns its value to the caller, does not remove it. readEventFromBus(category, subCategory) { const matchedEvent = store.state.applicationUser.eventBus.find(({ category, subCategory }) => category === category && subCategory === subCategory); - return matchedEvent.eventValue; + + return matchedEvent === undefined ? undefined : matchedEvent.eventValue; }, // Checks if an item is on the bus or not, useful when you don't care about the value.