title: RXSwift - takeUntil canceling before next event
body: <p>Following a similar example to question 39 here: <a href="http://reactivex.io/learnrx/" rel="nofollow">http://reactivex.io/learnrx/</a></p>
  
  <p>I'm trying to transform a method call <code>search(query: String)</code> into a sequence of those calls.
  They way I'm achieving this is by creating a <code>Variable</code> which I update with the <code>query</code> value every time 
  the <code>search(query: String)</code> method is called.</p>
  
  <p>Then I have this in my <code>init()</code>:</p>
  
  <pre><code>_ = queryVariable.asObservable().flatMap({ query -&gt; Observable&lt;[JSON]&gt; in
      return self.facebookSearch(query).takeUntil(self.queryVariable.asObservable())
  }).subscribeNext({ result in
      if let name = result[0]["name"].string {
          print(name)
      } else {
          print("problem")
      }
  })
  </code></pre>
  
  <p>If I type <code>"ABC"</code>, my <code>search(query: String)</code> method will be called 3 times with <code>"A"</code>, <code>"AB"</code>, <code>"ABC"</code>.
  That would be mapped to <code>seq(["A", "AB", "ABC"])</code> with <code>queryVariable.asObservable()</code>.
  Then I'm mapping it to Facebook searches (searching people by their names on Facebook).
  And with <code>subscribeNext</code> I print the name.
  If I don't use the <code>takeUntil</code>, it works as I'd expect, I get 3 sets of results, one for each of my queries(<code>"A"</code>, <code>"AB"</code>, <code>"ABC"</code>).</p>
  
  <p>But if I type fast (before Facebook has time to respond to the request), I'd want only one result, for the query <code>"ABC"</code>. That's why I added the <code>takeUntil</code>. With it I'd expect the <code>facebookSearch(query: String)</code> call to be ignored when the next <code>query</code> comes in, but it is being canceled for the current query, so with this <code>takeUntil</code> I end up printing nothing.</p>
  
  <p>Is this a known issue or am I doing something wrong?</p>