title: RxSwift - Observable removing used elements
body: <p>In my app, I have a collection of pickers. Each picker takes its values from a service.</p>
  
  <p>The app layout looks something like this:</p>
  
  <pre><code>--------------------
  -    picker 1      -
  --------------------
  -    add picker    -
  --------------------
  </code></pre>
  
  <p>You can tap <code>add picker</code> to add more pickers, which are placed in a <code>UIStackView</code>. Each picker is backed by its <code>UIViewController</code> and has its own viewModel, while the container view controller has a viewModel as well.</p>
  
  <p>After you tap <code>add picker</code> some times, you get something like this:</p>
  
  <pre><code>--------------------
  -    picker 1      -
  --------------------
  -    picker 2      -
  --------------------
  -    picker 3      -
  --------------------
  </code></pre>
  
  <p>When you tap each picker, I display a set of options to the user. The set of options comes from a web service, which is wrapped by the View Model in an <code>Observable&lt;OperationType&gt;</code>.</p>
  
  <p>Say the service returned <code>option 1</code>, <code>option 2</code>, <code>option 3</code>, and the user picks <code>option 1</code> for the first picker, I need that when the second picker opens to only offer the user <code>option 2</code> and <code>option 3</code>.</p>
  
  <p>In my main view model I have this code:</p>
  
  <pre><code>    var children = Variable&lt;[ChildViewModel]&gt;([])
  
      var allAvailableOperationTypes: Observable&lt;[OperationType]&gt; {
          return RequestManager.sharedInstance.rx
              .catalogues()
              .asObservable()
              .map { return $0.operationTypes }
          }
      }
  </code></pre>
  
  <p>I then created a new <code>Observable</code> to handle combining the last value from <code>allAvailableOperationTypes</code> and "remove" the ones already selected.</p>
  
  <p>Something like:</p>
  
  <pre><code>var availableOperationTypes: Observable&lt;[OperationType]&gt; {
      return allAvailablePriceOperationTypes
          .map { (operationTypes) in
              operationTypes.filter { // keep those not used in children }
            }
      }
  }
  </code></pre>
  
  <p>On the View Controller, I'm binding it to the button like:</p>
  
  <pre><code>    operationTypeButton.rx.tap
          .asObservable()
          .withLatestFrom(viewModel.availableOperationTypes)
          .subscribe(onNext: { [unowned self] (operationTypes) in
              self.presentPicker(forOperationTypes: operationTypes)
          })
          .addDisposableTo(disposeBag)
  </code></pre>
  
  <p>If the user selects a value on the first picker, and then adds a second one, the second picker will only include the "free" options. However, the first picker will still show all the options available.</p>
  
  <p>What I'd like to achieve, is for this to be hot, such that when the user taps the picker button, it only shows options he can pick.</p>