In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions. The remembered information is called the state of the system.
idle·loading·success·failure— 버튼 비활성화는 앱 로직이 아니다- 상태 머신 — 스테이트차트·UML 표기·TypeStates
- Signal — 읽은 곳만 다시 계산하는 반응성
- State Reducer 패턴 — reducer 를 넘겨 훅 동작을 바꾼다
- Redux 스타일 store 직접 구현
useGenerator— 핸들러를 async generator 로 받아 yield 마다 상태를 바꾼다
verbatimModuleSyntax 를 켜면 type 없는 import 는 출력에 그대로 남는다 — 타입만 가져올 땐 import type 으로 표시해야 한다(안 하면 TS1484).1
import type { A } from 'a'
- GitHub - privatenumber/fix-verbatim-module-syntax: CLI tool to auto-fix verbatimModuleSyntax errors
- TypeScript: TSConfig Reference - Docs on every TSConfig option
- Exploring TypeScript 5 features: Smaller, simpler, faster - LogRocket Blog
Footnotes
-
아래 TSConfig Reference 의
verbatimModuleSyntax: “any imports or exports without atypemodifier are left around. Anything that uses thetypemodifier is dropped entirely.” ↩
const emptyCsvFile = new File([''], 'default.csv', { type: 'text/csv' })
const emptyPngFile = new File([''], 'default.png', { type: 'image/png' })
formData.append('product_coupons', emptyCsvFile)
formData.append('product_imgs', emptyPngFile)
console.assert(emptyCsvFile.size === 0)
빈 파일을 FormData에 첨부하여 전송하는 방법 — File 은 Blob 이라 append 가 파일 필드로 받고, 파일명은 File 의 이름이 그대로 간다.1
File객체를 사용하여 빈 파일을 생성할 수 있다.- 파일의
MIME타입을 지정하여 타입에 맞는 빈 파일을 만들 수 있다. - 생성된 빈 파일을
FormData객체에 추가하여 전송할 수 있다.
이는 서버에 빈 형태의 파일을 전송할 때 유용하며, API 테스트 및 디폴트 값 설정에 활용될 수 있다.
Footnotes
-
FormData: append() - MDN: “This can be a string or Blob (including subclasses such as File).” / “The default filename for File objects is the file’s filename.” ↩
The Chrome DevTools Protocol (CDP) is a JSON-based protocol that connects debug and automation targets (such as browsing contexts and workers) with trusted debug and automation clients. It allows tools to instrument, inspect, debug, and profile Chromium, Chrome, and other Blink-based browsers.
- ChromeDevTools/devtools-frontend1
- cyrus-and/chrome-remote-interface2
- paulirish/awesome-chrome-devtools3
- Tencent/vConsole4
- liriliri/chii5
- devtools-frontend — get the code
- https://www.youtube.com/watch?v=RDi2snh8bpA
Footnotes
-
DevTools 화면 자체(TypeScript·CSS 웹앱). 이 프런트엔드가 CDP 로 대상과 대화하므로, 떼어다 다른 곳에 붙이면 자기만의 디버거가 된다 — 아래 chii 가 그렇게 쓴다. ↩
-
Node 에서 CDP 를 부르는 클라이언트. 명령·이벤트를 JS API 로 감싸서, 예컨대 페이지를 열고 나가는 요청을 전부 덤프하는 걸 몇 줄로 짠다. ↩
-
DevTools·CDP 생태계 링크 모음 — 학습 자료, 프로토콜 클라이언트, DevTools 프런트엔드를 다른 플랫폼에 쓰는 법, 확장. 마지막 커밋이 2021-01 이라 최신 도구는 빠져 있다. ↩
-
모바일 웹 페이지 안에 띄우는 가벼운 콘솔 패널(로그·네트워크·요소·스토리지). CDP 없이 페이지 안에서 돈다 — WeChat 미니프로그램의 공식 디버깅 도구. ↩
-
weinre 같은 원격 디버거인데 화면을 최신 devtools-frontend 로 바꿨다. 디버깅할 페이지에 스크립트를 넣고, 다른 기기의 브라우저에서 DevTools 로 붙는다. ↩
The
Generatorobject is returned by a generator function and it conforms to both the iterable protocol and the iterator protocol.
useGenerator— 핸들러를 async generator 로 받아 yield 마다 상태를 바꾼다- Iterator Helpers — async generator 페이지네이션을
take로 조기 종료 - Maybe Monad — generator 로 early return
- Async iterators and generators - JakeArchibald.com1
- How to consume a paginated API using JavaScript async generators
- Why would anyone need JavaScript generator functions?
Footnotes
-
Streaming 작업 시 비동기처리 방법을 알려주고 있는데…경험이 없어서 일단 메모. ↩