react-dual-listbox icon indicating copy to clipboard operation
react-dual-listbox copied to clipboard

Is it possible to load async options?

Open oscarlnetoo opened this issue 6 years ago • 2 comments

Hello @jakezatecky,

I am needing to load async options from a remote source as the user types. Is it possible to do with this component?

oscarlnetoo avatar Jan 31 '19 23:01 oscarlnetoo

When you say "as the user types" are you referring to the filter input? Currently, there is no built-in mechanism for asynchronous load, as the component uses the same set of options for both list boxes and filterCallback is iterated through the already available options.

I definitely see value in having support for asynchronous loading of options based on user input. I am thinking it might make sense to have a property like asyncOptions where it is called in whenever the available filter changes and that it should return a list of options.

This would supersede the existing options property and likely would require that the selected property be an array of { label, value } options instead of just strings. I might follow the route of react-select and just create a separate component to import, AsyncDualListBox to enforce that requirement.

jakezatecky avatar Feb 01 '19 00:02 jakezatecky

Thank you for the reply!

Yes, I am referring to the filter input. I know the async component of react-select. It's the same idea, but I want a dual list instead of a select. I would appreciate that feature in your lib.

oscarlnetoo avatar Feb 01 '19 00:02 oscarlnetoo

An example of asynchronous loading of options using the onFilterChange callback is now present in the v6.0-dev branch.

jakezatecky avatar Mar 31 '23 14:03 jakezatecky