subject in rxjava

12
Subject in RxJava 장장장 [email protected]

Upload: -

Post on 06-Jan-2017

969 views

Category:

Software


1 download

TRANSCRIPT

Subject in RxJava장인수

[email protected]

Subject

1. AsyncSubject

2. BehaviorSubject

3. PublishSubject

4. ReplaySubject

What’s the Subject?A Subject is a sort of bridge or proxy that acts both as a

Subscriber and as an Observable. Because it is a Subscriber, it can subscribe to one or more Observables, and because it is an Observable, it can pass through the

items it observes by reemitting them, and it can also emit new items.

Subject = Observable + Subscriber Observable 과 Subscriber 연결하는 다리같은 역할

1. AsyncSubjectAsyncSubject 는 Observable 이 완료되었을 때 구독하고 있는

각 Observer 에게 관찰한 마지막 아이템만을 발행한다 .

not CompletedAsyncSubject 는 Observable 이 완료되었을 때 구독하고 있는

각 Observer 에게 관찰한 마지막 아이템만을 발행한다 .

2. BehaviorSubject기본적으로 BehaviorSubject 는 가장 최근에 관찰된 아이템과

그 후에 관찰된 나머지 아이템을 구독하는 Observer 에게 발행하는 Subject이다 .

3. PublishSubject기본적인 subject 객체다 .

구독한 시점부터 이후에 발생되어지는 이벤트들을 전달받습니다 .

4. ReplaySubject관찰한 모든 아이템을 버퍼에 저장하고 구독하는 Observer 에게 재생한다 .

Q & A

감사합니다 .

참고자료

• http://goo.gl/ztz2as

• http://reactivex.io/documentation/subject.html

• http://www.introtorx.com/Content/v1.0.10621.0/02_KeyTypes.html#AsyncSubject

• http://www.introtorx.com/Content/v1.0.10621.0/02_KeyTypes.html#BehaviorSubject

• http://reactivex.io/RxJava/javadoc/rx/subjects/BehaviorSubject.html

• http://www.introtorx.com/Content/v1.0.10621.0/02_KeyTypes.html#ReplaySubject

• https://tech.instacart.com/how-to-think-about-subjects-part-1/