Search code examples
rx-swiftrx-cocoa

Differences between "Share Side effect" and "Share Resources"


I'm studying RxSwift and RxCocoa. There are these explanations in the official document.

  1. Share side effect
  2. Share resource

Are they the same? If there is a difference, what difference is there? I don't understand just the explanations in the official document.

Thank you in advance for your answer.


Solution

  • The documentation shows exactly what it means by "Shares side effects" and "Shares computational resources" in the parentheses beside each phrase.

    The phrase "Shares side effects" means it uses share(replay: 1, scope: .whileConnected) while "shares computational resources" means it uses share(scope: .whileConnected).

    That tells you that sharing side effects will replay the last emitted value for every new subscription while sharing computational resources will not. Otherwise, they are the same.