Open History to see the last commit
1import { createStore } from 'solid-js/store'
2β
3export const [auth, setAuth] = createStore<Auth>({
4 status: 'loggedOut',
5 username: undefined,
6 login: (username: string) => {
7 setAuth({
8 status: 'loggedIn',
9 username,
10 })
11 },
12 logout: () => {
13 setAuth({
14 status: 'loggedOut',
15 username: undefined,
16 })
17 },
18})
19β
20export type Auth = {
21 login: (username: string) => void
22 logout: () => void
23 status: 'loggedOut' | 'loggedIn'
24 username?: string
25}