title: Observable, with Rx-Realm and Rx-Swift, doesn't stop firing [unless I enter .replay(n)]
body: <p>I have the following Realm Object:</p>
  
  <pre><code>class GeolocationObject: Object {
  
      dynamic var id: String = UUID().uuidString
  
      dynamic var latitude: Double = 0
      dynamic var longitude: Double = 0
  
      let addresses = LinkingObjects.init(fromType: AddressObject.self, property: "geolocation")
  
      override static func primaryKey() -&gt; String? {
          return "id"
      }
  
  }
  </code></pre>
  
  <p>I also have the linking Address Object (for simplicity reasons I have only a road property):</p>
  
  <pre><code>class AddressObject: Object {
  
      dynamic public var id: String = UUID().uuidString
      dynamic var road: String = ""
      dynamic var geolocation: GeolocationObject?
  
      override static func primaryKey() -&gt; String? {
          return "id"
      }
  
  }
  </code></pre>
  
  <p>As you can see I have a To-One Relationship with the <code>GeolocationObject</code> and for the needs of my application there is a chance that on the same Geolocation, I may have many <code>AddressObjects</code>. So there is a <code>LinkingObjects</code> property in my <code>GeolocationObject</code>.</p>
  
  <p>I have created a reactive abstraction layer with RxSwift and RxRealm (<code>RealmProvider</code> just provides a method for easier Realm write transactions):</p>
  
  <pre><code>class GeolocationViewModel {
  
      let disposeBag: DisposeBag
      let geolocationObject: GeolocationObject
      let id: String
  
      var latitude: Variable&lt;Double&gt;
      var longitude: Variable&lt;Double&gt;
  
      let addresses: Observable&lt;[AddressViewModel]&gt;
  
      init(geolocationObject: GeolocationObject) {
  
          self.disposeBag = DisposeBag()
          self.geolocationObject = geolocationObject
          self.id = self.geolocationObject.id
  
          self.latitude = Variable(self.geolocationObject.latitude)
          self.longitude = Variable(self.geolocationObject.longitude)
  
          self.addresses =
              Observable.array(from: self.geolocationObject.addresses)
                  .map({ $0.flatMap({ AddressViewModel.init(addressObject: $0) }) })    
  
          self.latitude.asObservable()
              .subscribe(onNext: { [unowned self] (latitude) in
                  RealmProvider.commitWrite {
                      self.geolocationObject.latitude = latitude
                  }
              })
              .disposed(by: disposeBag)
  
          self.longitude.asObservable()
              .subscribe(onNext: { [unowned self] (longitude) in
                  RealmProvider.commitWrite {
                      self.geolocationObject.longitude = longitude
                  }
              })
              .disposed(by: disposeBag)
  
      }
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>class AddressViewModel {
  
      let disposeBag: DisposeBag
      let addressObject: AddressObject
      let id: String
  
      var road: Variable&lt;String&gt;
  
      var geolocation: Variable&lt;GeolocationViewModel?&gt;
  
      init(addressObject: AddressObject) {
  
          self.disposeBag = DisposeBag()
          self.addressObject = addressObject
          self.id = self.addressObject.id
  
          self.road = Variable(self.addressObject.road)
  
          if let geolocationObject = self.addressObject.geolocation {
              self.geolocation = Variable(GeolocationViewModel.init(geolocationObject: geolocationObject))
          } else {
              self.geolocation = Variable(nil)
          }
  
          self.road.asObservable()
              .debug()
              .subscribe(onNext: { [unowned self] (road) in
                  RealmProvider.commitWrite {
                      self.addressObject.road = road
                  }
              })
              .disposed(by: disposeBag)
  
          self.geolocation.asObservable()
              .subscribe(onNext: { [unowned self] (geolocationViewModel) in
                  RealmProvider.commitWrite {
                      self.addressObject.geolocation = geolocationViewModel?.geolocationObject
                  }
              })
              .disposed(by: disposeBag)
  
  }
  </code></pre>
  
  <p>As you can see I have passed the <code>LinkingObjects</code> property as an <code>Observable</code>, so in case something changes, it will be notified.</p>
  
  <p>To cut a long story short, I create an address with a geolocation object.
  All is fine till now. I grab the <code>AddressViewType</code>, and I change the road (which is a <code>Variable</code>). If I have a subscription on the <code>AddressViewType</code> array through the <code>GeolocationViewType</code>, it is correctly notified, but it fires all the time.</p>
  
  <p>For example:</p>
  
  <pre><code>let geolocationViewModel = GeolocationViewModel(geolocationObject: GeolocationViewModel)
  let addressViewModel = AddressViewModel(addressObject: AddressObject())
  addressViewModel.road.value = test1
  addressViewModel.geolocation.value = geolocationViewModel
  
  geolocationViewModel.addresses.subscribe(onNext: { addressArray in
  
  print(addressArray[0].road) 
  
  })
  .disposed(by: disposeBag)
  </code></pre>
  
  <p>If I try to change the road on the addressViewModel like this:</p>
  
  <pre><code>addressViewModel.road.value = "Test2"
  </code></pre>
  
  <p>it correctly notifies the print statement and it prints. BUT it fires all the time with the new value! It doesn't send the print only once.</p>
  
  <p>I found that it stops if the <code>Observable</code> for the addresses on the <code>GeolocationObject</code> is like this:</p>
  
  <pre><code>self.addresses =
                  Observable.array(from: self.geolocationObject.addresses)
                      .map({ $0.flatMap({ AddressViewModel.init(addressObject: $0) }) })
                      .replay(1)
  </code></pre>
  
  <p>Later on I also added <code>.share()</code>
  Why does it fire all the time if I don't put <code>.replay(1)</code> ?
  Shouldn't it just send it once and stop?</p>