3

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.

  • What official document? Can you provide a link to where these terms are used? – Daniel T. Aug 26 '19 at 22:58
  • I was wondering when I looked at the document on the link below. https://github.com/ReactiveX/RxSwift/blob/master/Documentation/Traits.md – codecodecode Aug 27 '19 at 09:00
  • Driver - Can't error out. - Observe occurs on main scheduler. - Shares side effects (share(replay: 1, scope: .whileConnected)). – codecodecode Aug 27 '19 at 09:22
  • Signal - Can't error out. - Delivers events on Main Scheduler. - Shares computational resources (share(scope: .whileConnected)). - Does NOT replay elements on subscription. – codecodecode Aug 27 '19 at 09:23

1 Answers1

3

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.

Daniel T.
  • 32,821
  • 6
  • 50
  • 72