Rx (or Combine) wrapper for Sharing library #175
Replies: 1 comment
-
One thing that gives me pause is the random ID for the key. Take for instance the Your key, on the other hand, I think would redundantly observe the same thing because each instance of the key is getting its own, random ID. Fixing this might not be possible with this key, because its parameter is an unhashable closure that can be and do Depending on how you're using it, you may be able to tolerate the inefficiency. But that's what catches my eye. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
In my current project, many of our services expose state through Observables as their interface. As a result, I often find myself writing a lot of boilerplate code to bridge these observables into TCA bindings. Here’s a simplified example:
As the number of observables I need to listen to increases, this pattern leads to a lot of repetitive code.
To reduce this boilerplate, I tried adopting the Sharing library and created a custom key for Rx observables like this:
Now I can use it like this:
This works well so far, but I’d love to get feedback:
• Are there any trade-offs or pitfalls I should be aware of when using this approach?
• Is there a better or more idiomatic way to bridge RxSwift.Observable into Sharing?
Any insights or suggestions would be greatly appreciated. Thanks! 🙏
Beta Was this translation helpful? Give feedback.
All reactions