Search code examples
rx-swiftcombine

Alternative for BehaviorRelay in Swift Combine


As part of moving from RX to Combine. What exactly works like "BehaviorRelay" of RxRelay in Swift Combine?


Solution

  • As mentioned in this Cheat Sheet, an RxSwift BehaviorSubject is the same as the Combine CurrentValueSubject. A BehaviorRelay is a simple wrapper around a BehaviorSubject and could easily be recreated in Combine, but doesn't exist natively.