There is also a couple of additional guarantees that all sequence producers (`Observable`s) must honor.
모든 시퀀스 생성자(Observable)는 반드시 준수해야 하는 몇 가지 추가적인 보장이 있습니다.
It doesn't matter on which thread they produce elements, but if they generate one element and send it to the observer `observer.on(.next(nextElement))`, they can't send next element until `observer.on` method has finished execution.
요소를 생성하는 스레드가 무엇인지와는 상관없이, 하나의 요소를 생성하여 observer.on(.next(nextElement)) 메서드를 통해 관찰자(observer)에게 전달한 경우, observer.on 메서드의 실행이 완료되기 전에는 다음 요소를 보낼 수 없습니다.
_Producers also cannot send terminating .completed or .error in case .next event hasn’t finished._
또한, .next 이벤트가 완료되지 않은 상태에서는 .completed 또는 .error와 같은 종료 이벤트를 보낼 수 없습니다
In short, consider this example:
간단히 말해, 다음 예제를 고려해 보십시오:
someObservable
.subscribe { (e: Event<Element>) in
print("Event processing started")
// processing
print("Event processing ended")
}
this will awlays print:
항상 이렇게 프린트 될것입니다
Event processing started
Event processing ended
Event processing started
Event processing ended
Event processing started
Event processing ended
It can never print:
이렇게 출력되지는 않을 것입니다.
Event processing started
Event processing started
Event processing ended
Event processing ended
핵심은 이벤트 처리의 순차성을 보장하는것
[RxSwift] Creating an Observable that performs work (3) | 2024.12.24 |
---|---|
[RxSwift] Creating your own Observable (aka observable sequence) (2) | 2024.12.22 |
[RxSwift] Disposing (2) | 2024.12.18 |
[RxSwift] Scheduler.2 (1) | 2024.12.16 |
[RxSwift] Scheduler.1 (2) | 2024.12.12 |