-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add observer-pattern draft and tsconfig draft
- Not yet found drawio diagram for Observer Pattern.
- Loading branch information
문승훈
committed
Feb 10, 2025
1 parent
e19b3ea
commit 54846c1
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
docs/design-pattern/03-behavior-pattern/06-observer-pattern.md
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,39 @@ | ||
--- | ||
title: Observer Pattern | ||
description: Understand about the observer pattern | ||
tags: [design-pattern, behavior-pattern] | ||
keywords: [design pattern, command pattern] | ||
last_update: | ||
date: 2025-02-10 | ||
--- | ||
|
||
|
||
## Overview | ||
|
||
## When to use | ||
특정 객체의 상태가 변경될 때 다른 객체에게 알림을 전달해야 할 때 | ||
- 버튼 클릭시 Display 업데이트 | ||
- 이벤트 발생시 Display 업데이트 | ||
|
||
## Why to use | ||
|
||
## How to use | ||
Subject (주제) 와 Observer (관찰자)로 구성한다. | ||
|
||
|
||
### Push 방식 | ||
Subject 가 Observer 에게 데이터를 직접 전달한다. | ||
### Polling 방식 | ||
이벤트 발생시 Observer 가 필요한 데이터를 Subject 에게 요청한다. | ||
|
||
:::tip | ||
📝 **Polling 방식을 사용하라. Subject 변경에 유연하고, 필요한 데이터만 접근한다.** | ||
::: | ||
|
||
## Pros and Cons | ||
### Pros | ||
- 동기식으로 구현하면 디버깅이 쉽다. | ||
|
||
### Cons | ||
- Pub/Sub 패턴에 비해 객체간 의존성 강결합이 발생한다. \ | ||
Observer - Subject 간의 의존성이 강하다. |
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,61 @@ | ||
--- | ||
title: tsconfig usage tip | ||
description: How to use tsconfig.json | ||
tags: [typescript] | ||
keywords: [typescript] | ||
last_update: | ||
date: 2023-06-01 | ||
--- | ||
|
||
## rootDir | ||
Longest common path non-declaration input files. <br></br> | ||
Inferred value for rootDir is `src`. | ||
|
||
```log | ||
MyProj | ||
├── tsconfig.json | ||
├── src | ||
│ ├── a.ts | ||
│ ├── b.ts | ||
│ ├── sub | ||
│ │ ├── c.ts | ||
├── types.d.ts | ||
``` | ||
|
||
If `outDir` was dist, Typescript would write this tree: | ||
```log | ||
MyProj | ||
├── dist | ||
│ ├── a.js | ||
│ ├── b.js | ||
│ ├── sub | ||
│ │ ├── c.js | ||
``` | ||
|
||
|
||
:::info | ||
rootDir doesn't affect which files become part of the compilation. | ||
rootDir have to include all files need to be transpiled to `.js` | ||
::: | ||
|
||
```log | ||
MyProj | ||
├── tsconfig.json | ||
├── src | ||
│ ├── a.ts | ||
│ ├── b.ts | ||
│ ├── sub | ||
│ │ ├── c.ts | ||
├── types.d.ts | ||
├── hello.ts // error! | ||
``` | ||
|
||
```log | ||
hello.ts' is not under 'rootDir' '%PROJECT_DIR%/src'. 'rootDir' is expected to contain all source files. | ||
The file is in the program because: | ||
Matched by default include pattern '**/*' | ||
``` | ||
|
||
## Reference | ||
- [Typescriptlang.org](https://www.typescriptlang.org/tsconfig#composite) |