returned undefined if we don't have the event
This commit is contained in:
parent
b8d5f7a72d
commit
3ab5a97a4c
1 changed files with 4 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ export default {
|
||||||
readAndPopEventFromBus(category, subCategory) {
|
readAndPopEventFromBus(category, subCategory) {
|
||||||
// Match our item and find the index
|
// Match our item and find the index
|
||||||
const matchedEvent = store.state.applicationUser.eventBus.find(({ category, subCategory }) => category === category && subCategory === subCategory);
|
const matchedEvent = store.state.applicationUser.eventBus.find(({ category, subCategory }) => category === category && subCategory === subCategory);
|
||||||
|
|
||||||
const itemIndex = store.state.applicationUser.eventBus.indexOf(matchedEvent);
|
const itemIndex = store.state.applicationUser.eventBus.indexOf(matchedEvent);
|
||||||
|
|
||||||
// If the item exists, remove it.
|
// If the item exists, remove it.
|
||||||
|
|
@ -22,13 +23,14 @@ export default {
|
||||||
store.state.applicationUser.eventBus.splice(itemIndex, 1);
|
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.
|
// Finds the event on the bus and returns its value to the caller, does not remove it.
|
||||||
readEventFromBus(category, subCategory) {
|
readEventFromBus(category, subCategory) {
|
||||||
const matchedEvent = store.state.applicationUser.eventBus.find(({ category, subCategory }) => category === category && subCategory === 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.
|
// Checks if an item is on the bus or not, useful when you don't care about the value.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue