A BehaviorSubject will replay the latest or initial value in a next event to new subscribers. We will create a BehaviorSubject instance with an initial value of Test. We will start this section with a basic code setup and build on top of the previous example by just commenting out the sample code for PublishSubject:
executeProcedure(for: "BehaviorSubject"){ let disposeBag = DisposeBag()}
Then, we will create a subscription on it using subscribe(onNext:):
let behSubject = BehaviorSubject(value: "Test") let initialSubscripton = behSubject.subscribe(onNext: { print("Line number is \(#line) and value is" , $0) })
We have used the line debugging identifier as an easy way to distinguish this printout in the console by ...