I’m just starting to learn vuejs and try to understand the principle of communication between components.
The doc say here that for non-parent-child communication we can use a bus or vuex
I’ve tried a minimal test with :
1 “snowman” component = can be green or blue and can jump
1 “remote-control” component = with 3 buttons to change the snowman colour and make it jumping
The “bus” solution seems to me easy to understand :
But with the “vuex” test I made :
changing the colour of the snowman work great and seems logic to me,
but I’m confused about the way to make it jump using vuex.
Jumping is a “function” and not a “state”, so how can I tell the store to run a function of a component ?
For the moment the only solution I’ve found is to increment a property “isJumping” in the store and to watch it in the snowman component. But it doesn’t seem to be the way to do that sort of things. How should I do that ? Does the animation part should be in the store itself ?
Thank if you can help me, It’s the part that blocks me the most to go forward
Sorry my bad english, hope this understandable.