title: RxSwift. Subscription occurs twice
body: <p>I do not know RxSwift well enough, and could not figure out my problem on my own. I would be very grateful for the help. Sorry for my English.</p>
  
  <pre><code>//declare variables    
  
  var loadedImage = BehaviorRelay&lt;UIImage?&gt;(value: nil)
  
  //Subscribe when creating a cell
  
  loadedImage
              .do(onNext: { (_) in
                  cell.activityIndicator.startAnimating()
                  cell.activityIndicator.isHidden = false
              })
              .flatMap { (image) -&gt; Observable&lt;String&gt; in
                  guard let image = image else { return Observable.just("") }
                  return service.uploadPhoto(image: image)
              }
              .observeOn(MainScheduler.instance)
              .subscribeNext { (imageName) in
                  vc.createEventData.imageName = imageName
  
                  cell.activityIndicator.stopAnimating()
                  cell.activityIndicator.isHidden = true
  
                  let currentPhoto = self.object?.placeholderPhoto
                  let image = self.loadedImage.value
  
                  cell.photoEventImageView.image = image == nil ? currentPhoto : image
  
                  if let photoPath = self.object?.photoPath, image == nil {
                      if photoPath != "uploads/photos/.png" {
                          let url = URL(string: "http://test-around.profsoft.online/" + photoPath)
                          cell.photoEventImageView.kf.setImage(with: url)
  
                          if let r = photoPath.range(of: "/", options: .backwards) {
                              let imageName = photoPath.substring(from: r.upperBound)
                              vc.createEventData.imageName = imageName
                          }
                      }
                  }
  
              }
              .disposed(by: disposeBag)
  
  //I throw a signal when choosing a photo
  
     func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
          guard let image = info[.originalImage] as? UIImage else { return }
          loadedImage.accept(image)
          self.viewController?.dismiss(animated: true, completion: nil)
      }
  </code></pre>
  
  <p>I can’t understand why the subscription occurs 2 times. That is, I go to service.uploadPhoto (image: image) twice.</p>