export default {
  state: {
    isVisible: false,
    options: {
      text: '',
      autoDismiss: true,
    },
  },
  getters: {
    snackbarIsVisible(state) {
      return state.isVisible;
    },
    snackbarOptions(state) {
      return state.options;
    },
  },
  mutations: {
    CORE_CREATE_SNACKBAR(state, snackbarOptions = {}) {
      // reset
      state.isVisible = false;
      state.options = {};
      // set new options
      state.isVisible = true;
      // options include text, autoDismiss, duration, actionText, actionCallback,
      // hideCallback, bottomPosition
      state.options = snackbarOptions;
    },
    CORE_CLEAR_SNACKBAR(state) {
      state.isVisible = false;
      state.options = {};
    },
    CORE_SET_SNACKBAR_TEXT(state, text) {
      state.options.text = text;
    },
  },
};

export default {
  state: {
    isVisible: false,
    options: {
      text: '',
      // duration in ms, 0 indicates it should not automatically dismiss
      duration: 6000,
      actionText: '',
      actionCallback: null,
    },
  },
  getters: {
    snackbarIsVisible(state) {
      return state.isVisible;
    },
    snackbarOptions(state) {
      return state.options;
    },
  },
  actions: {
    showSnackbar({ commit }, { text, duration, actionText, actionCallback }) {
      commit('CORE_CREATE_SNACKBAR', { text, duration, actionText, actionCallback });
    },
    clearSnackbar({ commit }) {
      commit('CORE_CLEAR_SNACKBAR');
    }
  },
  mutations: {
    CORE_CREATE_SNACKBAR(state, snackbarOptions = {}) {
      // reset
      state.isVisible = false;
      state.options = {};
      // set new options
      state.isVisible = true;
      // options include text, duration, actionText, actionCallback,
      // hideCallback, bottomPosition
      state.options = snackbarOptions;
    },
    CORE_CLEAR_SNACKBAR(state) {
      state.isVisible = false;
      state.options = {};
    },
    CORE_SET_SNACKBAR_TEXT(state, text) {
      state.options.text = text;
    },
  },
};

Remove `autoDismiss` and add actions
Remove `autoDismiss` and add actions

- `autoDismiss: false` can be done by making duration `null`
in this case the snackbar won't dismiss until the button is clicked
on the snackbar item

- Now we can dispatch actions rather than commit mutations directly.
Per Vue 'best practices'
