Skip to content

Commit

Permalink
docs: Add observer-pattern draft and tsconfig draft
Browse files Browse the repository at this point in the history
- Not yet found drawio diagram for Observer Pattern.
  • Loading branch information
문승훈 committed Feb 10, 2025
1 parent e19b3ea commit 54846c1
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
39 changes: 39 additions & 0 deletions docs/design-pattern/03-behavior-pattern/06-observer-pattern.md
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 간의 의존성이 강하다.
61 changes: 61 additions & 0 deletions docs/typescript/11-tsconfig.md
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)

0 comments on commit 54846c1

Please sign in to comment.