useAsyncChoices
SourceHook that makes it easy to use an AsyncChoices definition.
This hook does the following:
1) Calls useListProps to get any dependencies for list
2) Calls list and passes through the dependencies and a query
object representing any query parameters for the async call
3) Calls useRetrieveProps to get any dependencies for retrieve
4) If there is a current value
retrieve is called and is passed the dependencies returned above
5) An object is returned with the available choices in choices
, the result of 2 in list
and result of 4 in selected
Parameter | Type | Description | |
---|---|---|---|
props.accumulatePages | boolean | Whether to accumulate pages as more results are fetched. For example if the first page of results is returned, then the next page is fetched then the combined results for the first two pages will be resolved. This resets whenever If this is true you must specify | |
props.query | Record | Any query string parameters for the request | |
props.trigger | "MANUAL"|"DEEP" | When to trigger the fetch. Defaults to If set to Defaults to 'DEEP'. | |
* | props.asyncChoices | AsyncChoicesInterface | See [AsyncChoices](doc:AsyncChoices] |
props.listOptions | Record | Any extra options to pass through to list These will be available in both useListProps and list under the | |
props.onRetrieveError | Function | If provided this function will be called whenever You can use this to do things like unset a value if it no longer exists. | |
props.onRetrieveSuccess | Function | If provided this function will be called whenever a value is successfully
resolved using | |
props.retrieveOptions | Record | Any extra options to pass through to retrieve These will be available in both useRetrieveProps and retrieve under the | |
props.value | ValueT[]|ValueT|null | The currently selected choice(s) - if any When specified the corresponding label(s) will be resolved automatically. |
Key | Type | Description |
---|---|---|
choices | ReturnType | See getChoices |
list | UseAsyncListingReturn | See useAsyncListing |
selected | UseAsyncValueReturn | See useAsyncValue |