I have a Vue 3 app. I'm using the Composition API as I've read it simplifies state management. As a result, I'm trying to to avoid using VueX. Perhaps, I've run into a scenario that warrants it. I currently have the following component structure in my app...
App
+---------------------------------------------------+
| |
| +-----------------+ +--------------------+ |
| | Component 1 | | Component 2 | |
| | +-------------+ | | | |
| | | Component A | | +--------------------+ |
| | +-------------+ | |
| | | |
| | +-------------+ | |
| | | Component B | | |
| | +-------------+ | |
| +-----------------+ |
| |
+---------------------------------------------------+
This whole app revolves around setting properties of a single item. The item can be initially set via Component 1 or in Component B. You can set properties on the item via Component A. When a user clicks a button in Component 2, I want to force a method in Component A to run. However, I haven't figured out how to do that.
Currently, in Component 2 I use this.$emit('forceRefresh') when the button is clicked. However, $emit only let's me go up the stack. I'm not sure how to go down the stack once I've reached the top. I tried using a computed property in Component A however, that didn't work. I feel stuck, like I'm doing this wrong. Still, I know there's a way, I'm just unsure of what that way is.