Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
RxJS Preview for Korean
RxJS Preview for Korean
Cargando en…3
×

Eche un vistazo a continuación

1 de 38 Anuncio

Más Contenido Relacionado

Similares a RxSwift (20)

Más reciente (20)

Anuncio

RxSwift

  1. 1. 고병학 22.11.09 RxSwift 비동기 라이브러리
  2. 2. 목차 • RxSwift 소개 • Observables • Publish, Behavior • Subjects, Relay • RxSwift operator들
  3. 3. RxSwift
  4. 4. RxSwift 소개 • 비동기 처리를 편하게 해줘서? • 코드를 깔끔하게 작성하고 싶어서? 왜 쓰는가?
  5. 5. 출처: https://github.com/ReactiveX/RxSwift; https://ios-development.tistory.com/95 RxSwift(Reactive eXtension Swift)란 관찰 가능한 연속성(순차적)형태와 함수형태의 연산자를 이용해서 비동기&이벤트를 위한 코드로 구성하고 있는 라이브러리
  6. 6. Observable
  7. 7. Observable은 뭘까? 대략 이런 모습입니다.
  8. 8. Observable은 뭘까? RxSwift 6.5.0 실제 구현 코드
  9. 9. Observable의 생명주기 • Create • Subscribe • onNext Observable이 끝나는 생명주기 • onComplete • onError • Disposed
  10. 10. Observable이 dispose되어야 메모리에서 사라진다.
  11. 11. Publish, Behavior
  12. 12. • Publish는 초기 값을 가지지 않는다. • Behavior는 초기 값을 가진다. Publish, Behavior
  13. 13. Subject, Relay
  14. 14. "Hot" and "Cold" Observables • 그냥 Observable은 subscribe가 호출될 때 생성된다. 즉 subscribe가 되기 전에는 옵저버블이 정의만 되어있고 생성되지 않았다. 이는 subscribe후에만 이벤트를 방출하는 Cold Observable이다. • Subject는 subscribe 전에도 생성이 가능하다. 누군가 자신을 구독하기 전에도 이벤트를 방출할 수 있다. 그래서 이를 Hot Observable이라고 한다. 출처: https://dongminyoon.tistory.com/58
  15. 15. • Subject는 Observable이면서 observer 역할을 한다. • Relay는 complete와 error를 발생시킬 수 없다. Dispose되기 전까지는 계속 작동한다. 따라서 Relay는 UI 작업을 하기에 적합하다. Relay는 RxCocoa 혹은 RxRelay를 필요로 한다. Subject, Relay
  16. 16. Subject, Relay 코드 차이
  17. 17. Operators
  18. 18. Operators RxSwift의 꽃이라고 불리는 operators • map • fl atMap • zip • merge • take • fi lter • debounce • throttle
  19. 19. map, flatMap 비슷한데 다른 • map은 연산값을 반환한다. • fl atMap은 Observable을 반환한다.
  20. 20. map 예제 (1/2)
  21. 21. map 예제 (2/2)
  22. 22. flatMap 예제
  23. 23. map과 flatMap 예제
  24. 24. 찾아보는 방법 https://reactivex.io/documentation/operators • marble 그림을 통해 이해할 수 있다. • 구슬: 데이터 • 화살표: Observable • 사각형: Operator • 세로 작대기: complete • 구슬을 드래그해서 알아볼 수 있다. • 볼드체는 대표 오퍼레이터
  25. 25. from https://reactivex.io/documentation/operators
  26. 26. zip https://reactivex.io/documentation/operators
  27. 27. merge https://reactivex.io/documentation/operators
  28. 28. combineLatest https://reactivex.io/documentation/operators
  29. 29. take https://reactivex.io/documentation/operators
  30. 30. filter https://reactivex.io/documentation/operators
  31. 31. Just https://reactivex.io/documentation/operators
  32. 32. debounce https://eunjin3786.tistory.com/80
  33. 33. throttle (공식 홈에 없었음) https://eunjin3786.tistory.com/80
  34. 34. 감사합니다

×