{"action":"created","comment":{"url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/comments/170845210","pull_request_review_id":99592056,"id":170845210,"diff_hunk":"@@ -21,11 +25,13 @@ export default function createCachedSelector(...funcs) {\n       selectorCreator = options.selectorCreator || createSelector;\n     }\n \n+    const isCacheKeyValid = cache.isCacheKeyValid || defaultCacheKeyValidator;\n+\n+    // Application receives this function\n     const selector = function(...args) {\n-      // Application receives this function\n       const cacheKey = resolver(...args);\n \n-      if (typeof cacheKey === 'string' || typeof cacheKey === 'number') {\n+      if (isCacheKeyValid(cacheKey)) {","path":"src/index.js","position":null,"original_position":28,"commit_id":"a995680e69cb705c56a34dea735e3927f5fc2743","original_commit_id":"6742aa2f12e26f3e1179b6a388320f34431b81f4","user":{"login":"xsburg","id":830824,"avatar_url":"https://avatars2.githubusercontent.com/u/830824?v=4","gravatar_id":"","url":"https://api.github.com/users/xsburg","html_url":"https://github.com/xsburg","followers_url":"https://api.github.com/users/xsburg/followers","following_url":"https://api.github.com/users/xsburg/following{/other_user}","gists_url":"https://api.github.com/users/xsburg/gists{/gist_id}","starred_url":"https://api.github.com/users/xsburg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xsburg/subscriptions","organizations_url":"https://api.github.com/users/xsburg/orgs","repos_url":"https://api.github.com/users/xsburg/repos","events_url":"https://api.github.com/users/xsburg/events{/privacy}","received_events_url":"https://api.github.com/users/xsburg/received_events","type":"User","site_admin":false},"body":"My reasoning for throwing an exception is this: according to current behaviour a cached selector will return `undefined` if the resolved key is invalid. This value will then be used in the user code and likely to throw a `TypeError` exception when accessed:\r\n```javascript\r\nconst user = getUserDetailsById(state, userId); // cached with re-reselect by userId\r\nreturn {\r\n    email: user.email // TypeError thrown\r\n};\r\n```\r\nSo the earlier we indicate to the source of the problem, the easier it will be to avoid long debugging trying to find the source of the `undefined`.\r\nTo sum up, I would say that warning would be enough if we still returned a correct result and didn't break the user code apart from caching.","created_at":"2018-02-27T08:26:39Z","updated_at":"2018-02-27T08:26:39Z","html_url":"https://github.com/toomuchdesign/re-reselect/pull/37#discussion_r170845210","pull_request_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/comments/170845210"},"html":{"href":"https://github.com/toomuchdesign/re-reselect/pull/37#discussion_r170845210"},"pull_request":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37"}},"in_reply_to_id":170449228},"pull_request":{"url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37","id":171204093,"html_url":"https://github.com/toomuchdesign/re-reselect/pull/37","diff_url":"https://github.com/toomuchdesign/re-reselect/pull/37.diff","patch_url":"https://github.com/toomuchdesign/re-reselect/pull/37.patch","issue_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/37","number":37,"state":"open","locked":false,"title":"Introduce cache objects supporting ES maps","user":{"login":"toomuchdesign","id":4573549,"avatar_url":"https://avatars3.githubusercontent.com/u/4573549?v=4","gravatar_id":"","url":"https://api.github.com/users/toomuchdesign","html_url":"https://github.com/toomuchdesign","followers_url":"https://api.github.com/users/toomuchdesign/followers","following_url":"https://api.github.com/users/toomuchdesign/following{/other_user}","gists_url":"https://api.github.com/users/toomuchdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/toomuchdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toomuchdesign/subscriptions","organizations_url":"https://api.github.com/users/toomuchdesign/orgs","repos_url":"https://api.github.com/users/toomuchdesign/repos","events_url":"https://api.github.com/users/toomuchdesign/events{/privacy}","received_events_url":"https://api.github.com/users/toomuchdesign/received_events","type":"User","site_admin":false},"body":"### What kind of change does this PR introduce? *(Bug fix, feature, docs update, ...)*\r\nFeature\r\n\r\n### What is the current behaviour? *(You can also link to an open issue here)*\r\nCurrently is only possible to store [cache keys of type `string` or `number`](https://github.com/toomuchdesign/re-reselect/blob/v1.0.1/src/index.js#L28). This check is currently made by the **core of the library** itself.\r\n\r\nIn order to allow the implementation of `cacheObject`s supporting [Maps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) or any other cache system, we might consider to find a different way of validating `cacheKey` entries, and let `cacheObject` free to receive any kind of `cacheKey`.\r\n\r\n### What is the new behaviour?\r\nThis approach consists of letting any `cacheObject` declare a new optional method named `isCacheKeyValid` _(very open to suggestions 😄 )_.\r\n\r\n` re-reselect` will call this method to validate the processed `cacheKey` or the default one if no `isCacheKeyValid` method is found.\r\n\r\n### Does this PR introduce a breaking change? *(What changes might users need to make in their application due to this PR?)*\r\nCurrently no changes, old `cacheObjects` are still relying on default `cacheKey` validation.\r\n\r\nThis PR might break only if an user used a custom `cacheObject` which declares a `isCacheKeyValid` method.\r\n\r\n### Other information:\r\nNot sure whether we should provide a default `cacheKey` validation method.\r\n\r\nStill work in progress.\r\n\r\n### Please check if the PR fulfills these requirements:\r\n- [ ] Tests for the changes have been added\r\n- [ ] Docs have been added / updated\r\n","created_at":"2018-02-24T23:56:26Z","updated_at":"2018-02-27T08:26:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5694f469783b06d31507c61ae9a63603d3ee4ec1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":546262159,"url":"https://api.github.com/repos/toomuchdesign/re-reselect/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true},{"id":847498381,"url":"https://api.github.com/repos/toomuchdesign/re-reselect/labels/work%20in%20progress","name":"work in progress","color":"0e8a16","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37/commits","review_comments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37/comments","review_comment_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/37/comments","statuses_url":"https://api.github.com/repos/toomuchdesign/re-reselect/statuses/a995680e69cb705c56a34dea735e3927f5fc2743","head":{"label":"toomuchdesign:cache-maps","ref":"cache-maps","sha":"a995680e69cb705c56a34dea735e3927f5fc2743","user":{"login":"toomuchdesign","id":4573549,"avatar_url":"https://avatars3.githubusercontent.com/u/4573549?v=4","gravatar_id":"","url":"https://api.github.com/users/toomuchdesign","html_url":"https://github.com/toomuchdesign","followers_url":"https://api.github.com/users/toomuchdesign/followers","following_url":"https://api.github.com/users/toomuchdesign/following{/other_user}","gists_url":"https://api.github.com/users/toomuchdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/toomuchdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toomuchdesign/subscriptions","organizations_url":"https://api.github.com/users/toomuchdesign/orgs","repos_url":"https://api.github.com/users/toomuchdesign/repos","events_url":"https://api.github.com/users/toomuchdesign/events{/privacy}","received_events_url":"https://api.github.com/users/toomuchdesign/received_events","type":"User","site_admin":false},"repo":{"id":82931976,"name":"re-reselect","full_name":"toomuchdesign/re-reselect","owner":{"login":"toomuchdesign","id":4573549,"avatar_url":"https://avatars3.githubusercontent.com/u/4573549?v=4","gravatar_id":"","url":"https://api.github.com/users/toomuchdesign","html_url":"https://github.com/toomuchdesign","followers_url":"https://api.github.com/users/toomuchdesign/followers","following_url":"https://api.github.com/users/toomuchdesign/following{/other_user}","gists_url":"https://api.github.com/users/toomuchdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/toomuchdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toomuchdesign/subscriptions","organizations_url":"https://api.github.com/users/toomuchdesign/orgs","repos_url":"https://api.github.com/users/toomuchdesign/repos","events_url":"https://api.github.com/users/toomuchdesign/events{/privacy}","received_events_url":"https://api.github.com/users/toomuchdesign/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toomuchdesign/re-reselect","description":"Enhance Reselect selectors with deeper memoization and cache management.","fork":false,"url":"https://api.github.com/repos/toomuchdesign/re-reselect","forks_url":"https://api.github.com/repos/toomuchdesign/re-reselect/forks","keys_url":"https://api.github.com/repos/toomuchdesign/re-reselect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toomuchdesign/re-reselect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toomuchdesign/re-reselect/teams","hooks_url":"https://api.github.com/repos/toomuchdesign/re-reselect/hooks","issue_events_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/events{/number}","events_url":"https://api.github.com/repos/toomuchdesign/re-reselect/events","assignees_url":"https://api.github.com/repos/toomuchdesign/re-reselect/assignees{/user}","branches_url":"https://api.github.com/repos/toomuchdesign/re-reselect/branches{/branch}","tags_url":"https://api.github.com/repos/toomuchdesign/re-reselect/tags","blobs_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/refs{/sha}","trees_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toomuchdesign/re-reselect/statuses/{sha}","languages_url":"https://api.github.com/repos/toomuchdesign/re-reselect/languages","stargazers_url":"https://api.github.com/repos/toomuchdesign/re-reselect/stargazers","contributors_url":"https://api.github.com/repos/toomuchdesign/re-reselect/contributors","subscribers_url":"https://api.github.com/repos/toomuchdesign/re-reselect/subscribers","subscription_url":"https://api.github.com/repos/toomuchdesign/re-reselect/subscription","commits_url":"https://api.github.com/repos/toomuchdesign/re-reselect/commits{/sha}","git_commits_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/commits{/sha}","comments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/comments{/number}","issue_comment_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/comments{/number}","contents_url":"https://api.github.com/repos/toomuchdesign/re-reselect/contents/{+path}","compare_url":"https://api.github.com/repos/toomuchdesign/re-reselect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toomuchdesign/re-reselect/merges","archive_url":"https://api.github.com/repos/toomuchdesign/re-reselect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toomuchdesign/re-reselect/downloads","issues_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues{/number}","pulls_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls{/number}","milestones_url":"https://api.github.com/repos/toomuchdesign/re-reselect/milestones{/number}","notifications_url":"https://api.github.com/repos/toomuchdesign/re-reselect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toomuchdesign/re-reselect/labels{/name}","releases_url":"https://api.github.com/repos/toomuchdesign/re-reselect/releases{/id}","deployments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/deployments","created_at":"2017-02-23T13:53:41Z","updated_at":"2018-02-25T00:06:26Z","pushed_at":"2018-02-27T08:00:38Z","git_url":"git://github.com/toomuchdesign/re-reselect.git","ssh_url":"git@github.com:toomuchdesign/re-reselect.git","clone_url":"https://github.com/toomuchdesign/re-reselect.git","svn_url":"https://github.com/toomuchdesign/re-reselect","homepage":"","size":423,"stargazers_count":191,"watchers_count":191,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":12,"open_issues":4,"watchers":191,"default_branch":"master"}},"base":{"label":"toomuchdesign:master","ref":"master","sha":"91ace75e11935a08edac3830e72fe80dc4c9847d","user":{"login":"toomuchdesign","id":4573549,"avatar_url":"https://avatars3.githubusercontent.com/u/4573549?v=4","gravatar_id":"","url":"https://api.github.com/users/toomuchdesign","html_url":"https://github.com/toomuchdesign","followers_url":"https://api.github.com/users/toomuchdesign/followers","following_url":"https://api.github.com/users/toomuchdesign/following{/other_user}","gists_url":"https://api.github.com/users/toomuchdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/toomuchdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toomuchdesign/subscriptions","organizations_url":"https://api.github.com/users/toomuchdesign/orgs","repos_url":"https://api.github.com/users/toomuchdesign/repos","events_url":"https://api.github.com/users/toomuchdesign/events{/privacy}","received_events_url":"https://api.github.com/users/toomuchdesign/received_events","type":"User","site_admin":false},"repo":{"id":82931976,"name":"re-reselect","full_name":"toomuchdesign/re-reselect","owner":{"login":"toomuchdesign","id":4573549,"avatar_url":"https://avatars3.githubusercontent.com/u/4573549?v=4","gravatar_id":"","url":"https://api.github.com/users/toomuchdesign","html_url":"https://github.com/toomuchdesign","followers_url":"https://api.github.com/users/toomuchdesign/followers","following_url":"https://api.github.com/users/toomuchdesign/following{/other_user}","gists_url":"https://api.github.com/users/toomuchdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/toomuchdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toomuchdesign/subscriptions","organizations_url":"https://api.github.com/users/toomuchdesign/orgs","repos_url":"https://api.github.com/users/toomuchdesign/repos","events_url":"https://api.github.com/users/toomuchdesign/events{/privacy}","received_events_url":"https://api.github.com/users/toomuchdesign/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/toomuchdesign/re-reselect","description":"Enhance Reselect selectors with deeper memoization and cache management.","fork":false,"url":"https://api.github.com/repos/toomuchdesign/re-reselect","forks_url":"https://api.github.com/repos/toomuchdesign/re-reselect/forks","keys_url":"https://api.github.com/repos/toomuchdesign/re-reselect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toomuchdesign/re-reselect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toomuchdesign/re-reselect/teams","hooks_url":"https://api.github.com/repos/toomuchdesign/re-reselect/hooks","issue_events_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/events{/number}","events_url":"https://api.github.com/repos/toomuchdesign/re-reselect/events","assignees_url":"https://api.github.com/repos/toomuchdesign/re-reselect/assignees{/user}","branches_url":"https://api.github.com/repos/toomuchdesign/re-reselect/branches{/branch}","tags_url":"https://api.github.com/repos/toomuchdesign/re-reselect/tags","blobs_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/refs{/sha}","trees_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toomuchdesign/re-reselect/statuses/{sha}","languages_url":"https://api.github.com/repos/toomuchdesign/re-reselect/languages","stargazers_url":"https://api.github.com/repos/toomuchdesign/re-reselect/stargazers","contributors_url":"https://api.github.com/repos/toomuchdesign/re-reselect/contributors","subscribers_url":"https://api.github.com/repos/toomuchdesign/re-reselect/subscribers","subscription_url":"https://api.github.com/repos/toomuchdesign/re-reselect/subscription","commits_url":"https://api.github.com/repos/toomuchdesign/re-reselect/commits{/sha}","git_commits_url":"https://api.github.com/repos/toomuchdesign/re-reselect/git/commits{/sha}","comments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/comments{/number}","issue_comment_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/comments{/number}","contents_url":"https://api.github.com/repos/toomuchdesign/re-reselect/contents/{+path}","compare_url":"https://api.github.com/repos/toomuchdesign/re-reselect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toomuchdesign/re-reselect/merges","archive_url":"https://api.github.com/repos/toomuchdesign/re-reselect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toomuchdesign/re-reselect/downloads","issues_url":"https://api.github.com/repos/toomuchdesign/re-reselect/issues{/number}","pulls_url":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls{/number}","milestones_url":"https://api.github.com/repos/toomuchdesign/re-reselect/milestones{/number}","notifications_url":"https://api.github.com/repos/toomuchdesign/re-reselect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toomuchdesign/re-reselect/labels{/name}","releases_url":"https://api.github.com/repos/toomuchdesign/re-reselect/releases{/id}","deployments_url":"https://api.github.com/repos/toomuchdesign/re-reselect/deployments","created_at":"2017-02-23T13:53:41Z","updated_at":"2018-02-25T00:06:26Z","pushed_at":"2018-02-27T08:00:38Z","git_url":"git://github.com/toomuchdesign/re-reselect.git","ssh_url":"git@github.com:toomuchdesign/re-reselect.git","clone_url":"https://github.com/toomuchdesign/re-reselect.git","svn_url":"https://github.com/toomuchdesign/re-reselect","homepage":"","size":423,"stargazers_count":191,"watchers_count":191,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":12,"open_issues":4,"watchers":191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37"},"html":{"href":"https://github.com/toomuchdesign/re-reselect/pull/37"},"issue":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/37"},"comments":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/toomuchdesign/re-reselect/statuses/a995680e69cb705c56a34dea735e3927f5fc2743"}},"author_association":"OWNER"}}
{"actor":{"display_login":"xsburg"}}