From ed8d087d4d5d1c46b0b1f7a11c71eb3949be5dd1 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Sat, 17 Sep 2016 23:03:02 -0700 Subject: [PATCH 1/7] Refactored Async. Cache not yet implemented. Pushing for discussion --- CHANGES.md | 1 - README.md | 1 - examples/src/components/GithubUsers.js | 6 +- src/Async.js | 264 ++++----- src/AsyncCreatable.js | 4 - test/Async-test.js | 768 ++++++------------------- 6 files changed, 309 insertions(+), 735 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fb04ed4672..451b929481 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,7 +19,6 @@ Multiple values are now submitted in multiple form fields, which results in an a ## New Select.Async Component `loadingPlaceholder` prop -`autoload` changed to `minimumInput` and now controls the minimum input to load options `cacheAsyncResults` -> `cache` (new external cache support) - defaults to true ## Fixes & Other Changes diff --git a/README.md b/README.md index b86a3f0a6f..532bf58cac 100644 --- a/README.md +++ b/README.md @@ -383,7 +383,6 @@ function onInputKeyDown(event) { placeholder | string\|node | 'Select ...' | field placeholder, displayed when there's no value scrollMenuIntoView | bool | true | whether the viewport will shift to display the entire menu when engaged searchable | bool | true | whether to enable searching feature or not - searchingText | string | 'Searching...' | message to display whilst options are loading via asyncOptions, or when `isLoading` is true searchPromptText | string\|node | 'Type to search' | label to prompt for search input tabSelectsValue | bool | true | whether to select the currently focused value when the `[tab]` key is pressed value | any | undefined | initial field value diff --git a/examples/src/components/GithubUsers.js b/examples/src/components/GithubUsers.js index 378792d9f2..582c131340 100644 --- a/examples/src/components/GithubUsers.js +++ b/examples/src/components/GithubUsers.js @@ -31,6 +31,10 @@ const GithubUsers = React.createClass({ }); }, getUsers (input) { + if (!input) { + return Promise.resolve({ options: [] }); + } + return fetch(`https://api.github.com/search/users?q=${input}`) .then((response) => response.json()) .then((json) => { @@ -53,7 +57,7 @@ const GithubUsers = React.createClass({ return (

{this.props.label}

- +