Streamline syncing between components' state and Vuex
- Related discussion: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15333#note_213672404
While developing some frontend features, we sometimes need to reflect a component's state in a Vuex store. In the past, we've dealt with this by developing wrapper components that take care of keeping the component and the store in sync:
-
gl-modal-vuex: this component wrapsgl-modaland keeps its visibility in sync with a store module -
gl-toggle-vuex: this one wrapsgl-togglein order to sync the toggle's state with the store
This raises a few questions:
- Should GitLab UI components have support for syncing their state with Vuex out of the box?
- If the answer is yes, how should we implement this support?
- Should it be by providing wrapper components? This would basically mean that we would need to move
gl-modal-vuexandgl-toggle-vuexto GitLab UI - Or should our components support this in their base implementation?
- In any case, are we able to abstract this pattern enough that we don't have to reimplement it for each component that needs it (ie move the logic to a mixin)?
- Should it be by providing wrapper components? This would basically mean that we would need to move
Edited by Paul Gascou-Vaillancourt