<commit_before>//
//  SearchedMangaCollectionViewController.swift
//  Yomu
//
//  Created by <NAME> on 7/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import AppKit
import RxSwift

protocol SearchedMangaDelegate: class {
  func searchedMangaDidSelected(_ viewModel: SearchedMangaViewModel)
  func closeView(_ sender: SearchedMangaCollectionViewController)
}

class SearchedMangaCollectionViewController: NSViewController {
  @IBOutlet weak var collectionView: NSCollectionView!
  @IBOutlet weak var mangaTitle: NSTextField!
  @IBOutlet weak var mangaTitleContainer: NSBox!
  @IBOutlet weak var progressIndicator: NSProgressIndicator!
  @IBOutlet weak var backButton: NSButton!

  weak var delegate: SearchedMangaDelegate?

  let collectionViewModel: SearchedMangaCollectionViewModel

  let disposeBag = DisposeBag()

  init(viewModel: SearchedMangaCollectionViewModel) {
    collectionViewModel = viewModel

    super.init(nibName: "SearchedMangaCollection", bundle: nil)!
  }

  required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  override func viewDidLoad() {
    super.viewDidLoad()

    collectionView.dataSource = self
    collectionView.delegate = self

    mangaTitle
      .rx.text
      .filter {
        $0.characters.count > 2
      }
      .throttle(0.5, scheduler: MainScheduler.instance)
      .subscribe(onNext: { [weak self] in
        guard let `self` = self else { return }

        self.collectionViewModel.search(term: $0) >>>> self.disposeBag
      }) >>>> disposeBag<commit_msg>Increase throttle to 1.0<commit_after>//
//  SearchedMangaCollectionViewController.swift
//  Yomu
//
//  Created by <NAME> on 7/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import AppKit
import RxSwift

protocol SearchedMangaDelegate: class {
  func searchedMangaDidSelected(_ viewModel: SearchedMangaViewModel)
  func closeView(_ sender: SearchedMangaCollectionViewController)
}

class SearchedMangaCollectionViewController: NSViewController {
  @IBOutlet weak var collectionView: NSCollectionView!
  @IBOutlet weak var mangaTitle: NSTextField!
  @IBOutlet weak var mangaTitleContainer: NSBox!
  @IBOutlet weak var progressIndicator: NSProgressIndicator!
  @IBOutlet weak var backButton: NSButton!

  weak var delegate: SearchedMangaDelegate?

  let collectionViewModel: SearchedMangaCollectionViewModel

  let disposeBag = DisposeBag()

  init(viewModel: SearchedMangaCollectionViewModel) {
    collectionViewModel = viewModel

    super.init(nibName: "SearchedMangaCollection", bundle: nil)!
  }

  required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  override func viewDidLoad() {
    super.viewDidLoad()

    collectionView.dataSource = self
    collectionView.delegate = self

    mangaTitle
      .rx.text
      .filter {
        $0.characters.count > 2
      }
      .throttle(1.0, scheduler: MainScheduler.instance)
      .distinctUntilChanged()
      .subscribe(onNext: { [weak self] in
        guard let `self` = self else {
          return
        }

        self.collectionViewModel.search(term: $0) >>>> self.disposeBag
      }) >>>> disposeBag
{'fraction_non_alphanumeric': 0.0906515580736544, 'fraction_numerical': 0.009442870632672332, 'mean_word_length': 3.851908396946565, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4439549', 'n_tokens_mistral': 1017, 'n_tokens_neox': 930, 'n_words': 231}