brunch

You can make anything
by writing

C.S.Lewis

by 으아한구렝 Feb 11. 2018

1. Hello RxSwift

그렇게 시작되었습니다. ‘둠칫둠칫’

Reactive Extensions 랍니다.

RxSwift finds the sweet spot between traditionally imperative Cocoa code and purist functional code. It allows you to react to events by using immutable code definitions to process asynchronously pieces of input in a deterministic, composable way.


Observables

비동기적으로 발생하는 이벤트를 각각 immutable snapshot 상태로 전달받아 처리할 수 있게 해줍니다.

Api request/response 등의 처리에 사용하는 finite observable sequences와 UI event 등의 처리에 사용하는 infinite observable sequences로 분류됩니다.


Operators

발생한 이벤트에 보다 복잡한 로직을 추가할 수 있습니다.

map, filter 등 매우 다양한 operator가 제공되며, 여러 개의 operator들을 조합하는 것도 가능합니다.


Schedulers

Dispatch queue의 기능을 하며, SerialDispatchQueueScheduler, ConcurrentDispatchQueueScheduler, OperationQueueScheduler 등이 있습니다.


App architecture

MVC 아키텍쳐에 rx를 적용하는 것도 가능하지만 MVP 아키텍쳐나 MVVM을 선택할 수도 있습니다.



의문점 / 공부할 부분

UISwitch의 on/off를 observe하는 예제 코드가 있는데, 이 코드는 누가 갖게 될까요? 로직은 가급적이면 view controller가 가졌으면 좋겠는데. 예를 들어 UITableViewCell 내에 있는 UISwitch라면, observe하게 만드는 코드는 누굴 줘야할까요?

NotificationCenter나 Grand Central Dispatch는 rx가 대체 해봐야 비슷하지 않을까요?

MVP, MVVM, RxTest


작가의 이전글 Custom font를 넣을 때 주의할 점
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari