action์ ํตํด action์ dispatch์ ์ ๋ฌํ๊ณ
reducer๊ฐ state๊ฐ์ ๊ฐฑ์ ํ๊ณ
dispatch๊ฐ subscribeํ๊ณ ์๋ ํจ์๋ค์ ํธ์ถํด
state๊ฐ์ ์ฐธ์กฐํ์ฌ UI๋ฅผ ๋ฐ๊ฟ์ค
state
type State = any
- ์ ์ฅ์(store)์ ์ํด ๊ด๋ฆฌ๋จ
- getState()์ ์ํด ๋ฐํ๋๋ ํ๋์ ์ํ๊ฐ
action
type Action = Object
- ์ด๋ค ์์ ์ ํ ์ง ์ค๋ช ํด์ฃผ๋ ์๋ฐ์คํฌ๋ฆฝํธ ์์ ๊ฐ์ฒด
- store์ ๋ฐ์ดํฐ๋ฅผ ๋ฃ๋ ์ ์ผํ ๋ฐฉ๋ฒ
- UI ์ด๋ฒคํธ์์ ์๋ , ๋คํธ์ํฌ ์ฝ๋ฐฑ์์ ์๋ , ์น์์ผ๊ณผ ๊ฐ์ ๋ค๋ฅธ ์์ค์์ ์๋ ๋ชจ๋ ๋ฐ์ดํฐ๋ ์ก์ ์ผ๋ก์จ ๋ณด๋ด์ง
reducer
type Reducer<S, A> = (state: S, action: A) => S
- ๋์ ๊ฐ๊ณผ ๊ฐ์ ๋ฐ์ ์๋ก์ด ๋์ ๊ฐ์ ๋ฐํํ๋ ํจ์
- ๊ฐ๋ค์ ์ปฌ๋ ์ ์ ๋ฐ์ ํ๋์ ๊ฐ์ผ๋ก ์ค์ด๋๋ฐ ์ฌ์ฉ
- ์๋ฐ์คํฌ๋ฆฝํธ์ Array.prototype.reduce()์ ํด๋น
- ๋์ ๊ฐ : ์ํ ๊ฐ์ฒด, ๋์ ๋ ๊ฐ : ์ก์
- ์ฃผ์ด์ง ์ด์ ์ํ์ ์ก์ ์์ ์๋ก์ด ์ํ๋ฅผ ๊ณ์ฐ
- ๊ฐ์ ์ ๋ ฅ์ด ์์ผ๋ฉด ๊ฐ์ ์ถ๋ ฅ์ ๋ฐํํ๋ ์์ํจ์
- APIํธ์ถ์ ๋ฆฌ๋์ ์์ ๋ฃ์ง ๋ง๊ฒ
dispatch
type BaseDispatch = (a: Action) => Action
type Dispatch = (a: Action | AsyncAction) => any
- ์ก์ ์ด๋ ๋น๋๊ธฐ ์ก์ ์ ๋ฐ๋ ํจ์
์ค์ต - github repository
https://github.com/yuiseo/study_redux
GitHub - yuiseo/study_redux
Contribute to yuiseo/study_redux development by creating an account on GitHub.
github.com
๋๊ธ