-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[박상범] 챕터 7: 자바스크립트 디자인 패턴 (1/3) #42
The head ref may contain hidden characters: "\uCC55\uD1307_1/\uBC15\uC0C1\uBC94"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘 읽었습니다 👍 👍 궁금한 점 하나 남겼어요!!
## 7.4 노출 모듈 패턴 | ||
일만이 행님이 답답해서 만든 패턴 | ||
|
||
비공개 함수와 속성에 접근하는 공개 포인터를 만듦. | ||
이렇게 하면 모듈 가장 아래에 위치한 공개 객체를 더 알아보기 쉬워서 가독성 좋음 | ||
|
||
> 회사에서도 커스텀 훅은 다 노출 모듈 패턴으로 작성함 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const foo1;
const foo2;
const bar1;
// ...
const public = {
foo1, foo2
}
export default public;
대략 이런 모습으로 이해하면 될까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요 전 아래와 같이 좀 더 일반적인 커스텀 훅 형태를 생각했어요!
const useWebView = () => {
const [isWebView, setIsWebView] = useState(false);
useEffect(() => {
if (isWebView) return;
if (typeof window !== 'undefined' && !!window.ReactNativeWebView) {
setIsWebView(true);
}
}, [isWebView]);
return {
isWebView,
};
};
export default useWebView;
노출 모듈 패턴이 실제로 커스텀 훅과 완전 일치하지 않을 수 있지만! 노출 모듈 패턴의 개념적 특성을 일부 따르고 있다고 봤어요
특히 내부 상태를 캡슐화하고 외부에는 필요한 값만 노출한다는 점에서 유사하다고 생각했슴다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아 말씀하신대로 이렇게도 적용 예로 볼 수 있겠군요 ?!? 👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정리 깔끔하네요👍 잘 읽었습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
노출 모듈 패턴 설명 감사함니다 , ,
No description provided.