0.9.0 • Published 10 months ago
vaxee v0.9.0
Overview
Vaxee is a simple and easy-to-use library for Vue 3 to manage the state of your application.
- ✨ Simple and intuitive API.
- 💪 Incredible TypeScript support.
- 🤯 Includes a
request
function. - 🫡 Improved DX with reactivity.
Documentation
You can find the documentation and installation steps on the website.
Demo
Let's create a huge demo store with a user and auth logic.
import { createStore } from "vaxee";
import { fetchUser, signIn, parseJwt } from "~/user";
export const useUserStore = createStore(
"user",
({ state, getter, request }) => {
const tokens = state(
{
access: "",
refresh: "",
},
{
persist: "user.tokens",
}
);
const isAuthorized = getter(
() => tokens.value.access && tokens.value.refresh
);
const userId = getter(() => parseJwt(tokens.value.access).sub);
const signIn = async (email: string, password: string) => {
tokens.value = await signIn(email, password);
};
const user = request(() => fetchUser(userId.value));
return {
user,
isAuthorized,
};
}
);
Now, let's use this store in a component.
<script setup>
import { watch } from "vue";
import { useUserStore } from "../stores/user";
const {
isAuthorized,
user: { data: user, refresh: refreshUser },
} = useUserStore();
watch(isAuthorized, (isAuthorized) => {
if (isAuthorized) {
refreshUser();
}
});
</script>
<template>
<div>
<p>Authorized: {{ isAuthorized }}</p>
<p>User: {{ user.firstName }} {{ user.lastName }}</p>
</div>
</template>
Author
0.8.4
10 months ago
0.9.0
10 months ago
0.8.1
11 months ago
0.7.2
11 months ago
0.8.0
11 months ago
0.7.1
11 months ago
0.8.3
11 months ago
0.8.2
11 months ago
0.7.0
11 months ago
0.6.2
11 months ago
0.6.1
11 months ago
0.6.0
11 months ago
0.5.5
11 months ago
0.5.4
11 months ago
0.5.3
11 months ago
0.5.2
11 months ago
0.5.1
12 months ago
0.5.0
12 months ago
0.4.1
12 months ago
0.4.0
12 months ago
0.3.2
12 months ago
0.3.1
12 months ago
0.3.0
1 year ago
0.2.0
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago
0.0.5
1 year ago
0.0.3
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago