Replies: 1 comment
-
|
진짜 많은 소스 코드를 분석했군요!! 저도 봐볼게요! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
느낀 점
아직까지도 100%로 Observer Pattern에 대해 이해하지는 못했지만 어디에서 활용할 수 있을지 정도는 충분히 감을 잡은것 같다. 이번 상태 관리 시스템 만들기를 하면서 그동안 동작하는 방식이 궁금해왔던
Redux,Zustand,Tanstack Query,SWR등 소스코드를 분석하면서 Observer Pattern과 어느정도 연관이 있다는것을 알았다. Zustand와 SWR 같은 경우 Provider를 사용하지 않는게 신기했었지만, 소스 코드를 봐보니useSyncExternalStore라는 React Hook API를 활용해서 만들었던 것이였다.결국 상태 관리는 Observer Pattern을 통해 상태 변경을 감지하고 알리는 방식이 중요한 핵심이라고 생각한다.
배운 점
useSyncExternalStore로 변경된 상태를 감지해 리렌더링을 발생하도록 한다.Object.defineProperty가 어떻게 쓰이는지 알 수 있었다.Beta Was this translation helpful? Give feedback.
All reactions