I have 2 non parent/child components. I'd like to run a function on component A by clicking a button on component B. I know that the eventbus is a solution but because I am already using Vuex I would like to do it the Vuex way but could not find an example on the internet.
            Asked
            
        
        
            Active
            
        
            Viewed 63 times
        
    1
            
            
        - 
                    Please post your code it will help to understand refer https://stackoverflow.com/help/how-to-ask – Sarjerao Ghadage Sep 27 '19 at 14:34
1 Answers
1
            Have component A mutate some state that component B is watching. When component B see's a change to that state, run your function.
The mutation could be as simple as flipping a boolean or incrementing a number. Anything to trigger the watch in the other component.
Here is how to setup the watch: https://stackoverflow.com/a/44347195/1409310
 
    
    
        Joseph Connolly
        
- 891
- 11
- 21
