Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 355
codecodecode Avatar asked Nov 30 '25 16:11

codecodecode


1 Answers

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.

like image 125
Daniel T. Avatar answered Dec 02 '25 13:12

Daniel T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!