링크
<aside>
📌 목차
</aside>
Operator
- 퍼블리셔가 방출한 값에 대해 작업을 수행하고 다운스트림으로 내려보내는 메서드
- Operator 또한 Publisher 이다.
- Be careful when using any operators that buffer values such as
collect
or flatMap
to avoid memory problems.
Collection values
collect()
- 업스트림이 방출한 값들을 하나의 array 로 변환해서 방출한다.
- 방출 시점 = 업스트림이 complete 될때 !!! (순서: 어레이 방출 → finished)
주의할점
- collect() 는 업스트림이 끝나기 전까지 계속 받는다
- They will use an unbounded amount of memory to store received values as they won’t emit before the upstream finishes.
collect(2)
- 전달된 수 만큼 chopping 한다
- 예시:
[1, 2, 3, 4. 5].publisher.collect(2)
- [1 , 2] → [3, 4] → [5] → finished