Should I use Vuex Store + watch variable as a way to simulate event?

74 Views Asked by At

Since I do not have a lot of experience in web development, I was wondering if this is a pattern or anti-pattern in Vue2.

  1. Have a variable "callId" in Vuex store. By default it is empty.
  2. When a call has arrived, set variable callId to the newly arrived call's id.
  3. Any Vue Component interested in this event can map this variable from state and watch it -> when it changes to non empty value, it means there's a new call

This way events could be simulated via Vuex. I thought of using event bus, but I've been told it is not recommended.

0

There are 0 best solutions below