         sortFilterView.isHidden = true
         if !searchTerm.isEmpty {
             autocomplete(withQuery: searchText)
+            timer?.invalidate()
+            timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.searchForProducts), userInfo: nil, repeats: false)
         } else {
             searchProductsView.isHidden = true
         }

import UIKit

private let reuseIdentifier = "productCell"

class RCHSearchViewController: UIViewController {


            pickerView.isHidden = true
            let titleString = "Sort: \(currentSort.rawValue)"
            sortButton.setTitle(titleString, for: .normal)
        }
    }
    
