forked from kookmin-sw/cap-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
36 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { atom } from 'recoil'; | ||
|
||
import { type AuthState } from './auth.model'; | ||
|
||
export const authState = atom<AuthState>({ | ||
key: 'authState', | ||
default: { | ||
isLogin: false, | ||
token: undefined, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { useRecoilState, useRecoilValue } from 'recoil'; | ||
|
||
import { authState, getIsLogin } from './auth.model'; | ||
import { authState } from './auth.atom'; | ||
import { getIsLogin } from './auth.selector'; | ||
|
||
export const useAuthState = () => useRecoilState(authState); | ||
export const useAuthIsLogin = () => useRecoilValue(getIsLogin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,4 @@ | ||
import { atom, selector } from 'recoil'; | ||
|
||
export interface AuthState { | ||
isLogin: boolean; | ||
token?: string; | ||
} | ||
|
||
export const authState = atom<AuthState>({ | ||
key: 'authState', | ||
default: { | ||
isLogin: false, | ||
token: undefined, | ||
}, | ||
}); | ||
|
||
export const getIsLogin = selector<boolean>({ | ||
key: 'authState/isLogin', | ||
get: ({ get }) => { | ||
const auth = get(authState); | ||
return auth.isLogin; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { selector } from 'recoil'; | ||
|
||
import { authState } from './auth.atom'; | ||
|
||
export const getIsLogin = selector<boolean>({ | ||
key: 'authState/isLogin', | ||
get: ({ get }) => { | ||
const auth = get(authState); | ||
return auth.isLogin; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export { type AuthState, authState, getIsLogin } from './auth.model'; | ||
export { useAuthState, useAuthIsLogin } from './auth.hook'; | ||
export {} from './auth.action'; | ||
export * from './auth.action'; | ||
export * from './auth.atom'; | ||
export * from './auth.hook'; | ||
export * from './auth.model'; | ||
export * from './auth.selector'; |