Browse Source

status vs sttore

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
858e2a6392
  1. 33
      client/src/store/index.ts
  2. 3
      client/src/views/Home.vue

33
client/src/store/index.ts

@ -2,19 +2,40 @@ import { auth } from "./auth.module";
import { createStore } from 'vuex'
import { getStatusGenerator } from "@/services/analytics.service";
const SET_ANALYTICS_STATUS = 'setAnalyticsStatus';
// import { notify } from "@kyvg/vue3-notification";
export default createStore({
const SET_ANALYTICS_STATUS = 'SET_ANALYTICS_STATUS';
const _SET_STATUS_GENERATOR = '_SET_STATUS_GENERATOR';
type State = {
analyticStatus: string,
_statusGenerator: AsyncIterableIterator<string>
}
const store = createStore<State>({
state: {
analyticStatus: 'loading...'
analyticStatus: 'loading...',
_statusGenerator: null
},
mutations: {
[SET_ANALYTICS_STATUS](state, status: string) {
state.analyticStatus = status;
},
[_SET_STATUS_GENERATOR](state, generator: AsyncIterableIterator<string>) {
this._statusGenerator = generator;
}
},
actions: {
async runStatusGenerator({commit}) {
async _runStatusGenerator({commit, state}) {
// notify({
// title: "Authorization",
// text: "You have been logged in!",
// });
if(state._statusGenerator !== null) {
return;
}
const g = getStatusGenerator();
for await (const data of g) {
// this.status = data.toLowerCase();
@ -26,3 +47,7 @@ export default createStore({
auth
}
})
store.dispatch('_runStatusGenerator');
export default store;

3
client/src/views/Home.vue

@ -32,9 +32,6 @@ export default defineComponent({
clearAllLabeling() {
this.$refs.graph.rerender();
}
},
mounted: function name() {
this.$store.dispatch('runStatusGenerator');
}
});
</script>

Loading…
Cancel
Save