{"action":"created","issue":{"url":"https://api.github.com/repos/domainr/domainr-search-box/issues/19","repository_url":"https://api.github.com/repos/domainr/domainr-search-box","labels_url":"https://api.github.com/repos/domainr/domainr-search-box/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/domainr/domainr-search-box/issues/19/comments","events_url":"https://api.github.com/repos/domainr/domainr-search-box/issues/19/events","html_url":"https://github.com/domainr/domainr-search-box/pull/19","id":176196002,"number":19,"title":"Delay searching by 500 ms on each keypress","user":{"login":"dubcanada","id":120325,"avatar_url":"https://avatars.githubusercontent.com/u/120325?v=3","gravatar_id":"","url":"https://api.github.com/users/dubcanada","html_url":"https://github.com/dubcanada","followers_url":"https://api.github.com/users/dubcanada/followers","following_url":"https://api.github.com/users/dubcanada/following{/other_user}","gists_url":"https://api.github.com/users/dubcanada/gists{/gist_id}","starred_url":"https://api.github.com/users/dubcanada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dubcanada/subscriptions","organizations_url":"https://api.github.com/users/dubcanada/orgs","repos_url":"https://api.github.com/users/dubcanada/repos","events_url":"https://api.github.com/users/dubcanada/events{/privacy}","received_events_url":"https://api.github.com/users/dubcanada/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-10T18:47:58Z","updated_at":"2016-09-10T19:08:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/domainr/domainr-search-box/pulls/19","html_url":"https://github.com/domainr/domainr-search-box/pull/19","diff_url":"https://github.com/domainr/domainr-search-box/pull/19.diff","patch_url":"https://github.com/domainr/domainr-search-box/pull/19.patch"},"body":"Currently it searches on every single key press (including starting a search so single letter domains so on until you reach your desired domain). So if you want to search trial.com you would consume 9 API calls (one for t, one for tr, one for tri, etc etc). That is a bit ridiculous and should be delayed for a bit so two simultaneous key presses (or very very close) don't trigger multiple API calls.\r\n\r\nThis delays the searching by 500ms on each keypress, that may be a bit high so I'm open for suggestions."},"comment":{"url":"https://api.github.com/repos/domainr/domainr-search-box/issues/comments/246130018","html_url":"https://github.com/domainr/domainr-search-box/pull/19#issuecomment-246130018","issue_url":"https://api.github.com/repos/domainr/domainr-search-box/issues/19","id":246130018,"user":{"login":"connyay","id":597300,"avatar_url":"https://avatars.githubusercontent.com/u/597300?v=3","gravatar_id":"","url":"https://api.github.com/users/connyay","html_url":"https://github.com/connyay","followers_url":"https://api.github.com/users/connyay/followers","following_url":"https://api.github.com/users/connyay/following{/other_user}","gists_url":"https://api.github.com/users/connyay/gists{/gist_id}","starred_url":"https://api.github.com/users/connyay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/connyay/subscriptions","organizations_url":"https://api.github.com/users/connyay/orgs","repos_url":"https://api.github.com/users/connyay/repos","events_url":"https://api.github.com/users/connyay/events{/privacy}","received_events_url":"https://api.github.com/users/connyay/received_events","type":"User","site_admin":false},"created_at":"2016-09-10T19:08:47Z","updated_at":"2016-09-10T19:08:47Z","body":"Thoughts on making this an option? Maybe with a default of ~100ms?\r\n\r\n```diff\r\ndiff --git a/src/search-box.js b/src/search-box.js\r\nindex 1e1ca07..10dca9a 100644\r\n--- a/src/search-box.js\r\n+++ b/src/search-box.js\r\n@@ -24,6 +24,8 @@ var SearchBox = function(options) {\r\n   this._last = 0;\r\n   this._cache = {};\r\n   this._listeners = {};\r\n+\r\n+  this._searchTimer = null;\r\n   this._renderer = defaultRenderer;\r\n \r\n   this._in = options.observe;\r\n@@ -62,13 +64,20 @@ var SearchBox = function(options) {\r\n       window.open(self._client.registerURL(result.domain));\r\n     };\r\n   }\r\n+\r\n+  if (options.searchDelay !== undefined) {\r\n+    this_.searchDelay = options.searchDelay;\r\n+  } else {\r\n+    this_.searchDelay = 100;\r\n+  }\r\n };\r\n \r\n SearchBox.prototype = {\r\n   _input: function() {\r\n     if (this._state.query != this._in.value) {\r\n       this._state.query = this._in.value;\r\n-      this._search();\r\n+      window.clearTimeout(this._searchTimer);\r\n+      this._searchTimer = window.setTimeout(this._search.bind(this), this_.searchDelay);\r\n     }\r\n   },\r\n ```"}}
{"actor":{"display_login":"connyay"}}