     
     private func _doNextRequest() {
         var operation: NSOperation!
-        let state = State(copy: requestedState)
+        var state = State(copy: requestedState)
+        state.sequenceNumber = nextSequenceNumber
+        nextSequenceNumber += 1
         let completionHandler: CompletionHandler = { (content: [String: AnyObject]?, error: NSError?) in
-            // IMPORTANT: Mark the state as received.
-            self.receivedState = state
+            // Remove request from list of pending requests.
             if let index = self.pendingRequests.indexOf(operation) {
                 self.pendingRequests.removeAtIndex(index)
             }
+            
+            // IMPORTANT: If more recent results were already received, ignore those.
+            if self.receivedState != nil && self.receivedState!.sequenceNumber > state.sequenceNumber {
+                return
+            }
+            self.receivedState = state
+            
+            // Call the result handler.
             self.handleResults(content, error: error)
         }
         let query = Query(copy: state.query)

import Foundation


/// Delegate for `SearchHelper`.
public protocol SearchDelegate: class {
    func requestIsSlow(request: NSOperation, query: Query) -> Void

        /// Whether the current page is the initial page for this search state.
        public var isInitialPage: Bool { return initialPage == page }
        
        /// This state's sequence number.
        public var sequenceNumber: Int = 0
        
        /// Construct a default state.
        public init() {
        }
