2 분 소요

Observable 종류

  • Observable: 모든 이벤트 처리
public func subscribe(
    onNext: ((Element) -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • Single: onSuccess, onFailure 이벤트 처리
public func subscribe(
    onSuccess: ((Element) -> Void)? = nil,
    onFailure: ((Swift.Error) -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • Completable: onCompleted, onError 이벤트 처리
public func subscribe(
    onCompleted: (() -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • Maybe: onSuccess, onError, onCompleted 이벤트 처리
public func subscribe(
    onSuccess: ((Element) -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • Infallible: onNext, onCompleted 이벤트 처리
public func subscribe(
    onNext: ((Element) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • (RxCocoa) Driver: onNext, onCompleted 처리, MainScheduler
public func drive(
    onNext: ((Element) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • (RxCocoa) Signal: onNext, onCompleted 처리, MainScheduler
public func emit(
    onNext: ((Element) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable

Subscribe 종류

  • subscribe: Observable 기본 구독 방식
public func subscribe(
    onNext: ((Element) -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • (RxCocoa) bind: onError 를 처리하지 않는 구독 방식
public func bind(onNext: @escaping (Element) -> Void) -> Disposable
  • (RxCocoa) drive: onError 를 처리하지 않고 메인 스케줄러에서만 동작하는 구독 방식
public func drive(
    onNext: ((Element) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • (RxCocoa) emit: onError 를 처리하지 않고 메인 스케줄러에서만 동작하는 구독 방식
public func emit(
    onNext: ((Element) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable

Subject 종류, 정해진 데이터 뿐만 아니라, 새로운 데이터를 내보낼 수 있다.

  • Subject: Async, Behavior, Publish, Replay
public func subscribe(
    onNext: ((Element) -> Void)? = nil,
    onError: ((Swift.Error) -> Void)? = nil,
    onCompleted: (() -> Void)? = nil,
    onDisposed: (() -> Void)? = nil
) -> Disposable
  • (RxRelay) Relay: onNext 이벤트만을 처리한다.
public func accept(_ event: Element) {
    self.subject.onNext(event)
}

참고 URL


ReactiveX

카테고리: ,

업데이트:

댓글남기기