0.0.3 • Published 7 months ago
@vanyamate/sec-vue v0.0.3
SEC Vue
Support for sec
without combine
npm i @vanyamate/sec-vue
// /action/todo/getTodos.action.ts
const getTodosAction = function (userId: string): Array<Todo> {
return fetch(`/todos`).then((response) => response.json());
};
// /model/todo/todo.model.ts
import { store, effect } from '@vanyamate/sec-vue';
const getTodosEffect = effect(getTodosAction);
export const todoLoading = store(false)
.on(getTodosEffect, 'onBefore', (state) => {
state.value = true;
})
.on(getTodosEffect, 'onFinally', (state) => {
state.value = false;
});
import { useStore } from '@vanyamate/sec-vue';
const loading = useStore(todoLoading);
<template>
<h2>{{ loading ? 'Загрузка' : '' }}</h2>
</template>;