Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow to specify a different function to fetch results #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 17, 2022

Conversation

MaximeRnR
Copy link
Contributor

@MaximeRnR MaximeRnR commented May 6, 2022

This commit adds fetchingResult property to AutoCompleteElement;
That property can only be set using script;
If set the property will be call in autocomplete.ts#fetchingResult methods;

@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from 46920cc to 691e296 Compare May 6, 2022 19:56
@MaximeRnR MaximeRnR marked this pull request as ready for review May 6, 2022 20:04
@MaximeRnR MaximeRnR requested a review from a team as a code owner May 6, 2022 20:04
@MaximeRnR MaximeRnR requested a review from srt32 May 6, 2022 20:04
@theinterned theinterned requested review from theinterned and removed request for srt32 May 9, 2022 16:52
Copy link
Contributor

@theinterned theinterned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello πŸ‘‹ thank you for this contribution!

I left a few small notes, but I have a larger question about what it is you are wanting to achieve here.

Can you provide a bit more detail about why this feature should be added to the library? What specifically is your use case that the current implementation doesn't cover? Thanks again.

@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from 691e296 to ba350f1 Compare May 10, 2022 10:57
@MaximeRnR
Copy link
Contributor Author

Hello @theinterned πŸ‘‹ ! Thanks for you review!
I will try to be precise about the purpose of this feature πŸ˜‡

Currently, the way data are fetched is implemented in the component.
The component will do an XHR request to url given by the src property, I found it a bit limited for some reasons.
This forces the developer to create a end point on its http server to send HTML <li> formated data.

With this new property, the developer can specify the way it wants the data to be fetched.

For instance, my options are stored in a global variable, I can tell the component to retrieve it this way.

Another example, I already have a end point that give a list of name as json, I can tell the component that the way to retrieve thoses names is to call this endpoint then map those data as <li>elements.

Also the developer could want to add headers or auth token to its request.

As long as the fetchResult returns a Promise<string> it will works.

Hope I was clear thanks for your time ! ✌️

@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from ba350f1 to b396ba3 Compare May 10, 2022 11:19
This commit adds fetchResult property to AutoCompleteElement;
That property can only be set using script;
If set, the property will be call in autocomplete.ts#fetchResult method;
@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from b396ba3 to 2f791d2 Compare May 10, 2022 11:39
Copy link
Contributor

@theinterned theinterned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay thank you for the explanation!

I like the general direction. I've left some suggestions on how this could be simplified a bit.

@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from c032a7c to a264de9 Compare May 11, 2022 08:11
@MaximeRnR MaximeRnR force-pushed the add-custom-way-to-fetch-results branch from a264de9 to 0cc8573 Compare May 11, 2022 08:32
@MaximeRnR
Copy link
Contributor Author

Thanks for the feedbacks !

I did the changes you suggested ! I like the simplicity of the test πŸ’― ! I overthinked it with the mock fetch πŸ˜„

@MaximeRnR
Copy link
Contributor Author

I do not know the way you want the commits to be; I thought of squashing them to only 1 commit.

Copy link
Contributor

@theinterned theinterned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ thanks for all the updates! I left one additional suggestion then I think this is good to go.

As for squashing the commits: I wouldn't worry about it! They're fine as they are.

MaximeRnR and others added 4 commits May 13, 2022 17:50
fetchResult will be automatically typed as `typeof fragment`

Co-authored-by: Ned Schwartz <[email protected]>
Copy link
Contributor

@theinterned theinterned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ thank you for all the great contribution! This is rad.

I pushed a few small changes to fix some oopsies. I hope you don't mind.

@MaximeRnR
Copy link
Contributor Author

Thanks again for your time ! It was great collaborating with you πŸ˜„

@koddsson koddsson mentioned this pull request May 16, 2022
@theinterned theinterned merged commit 83cf377 into github:main May 17, 2022
@theinterned
Copy link
Contributor

This has been released https://github.com/github/auto-complete-element/releases/tag/v3.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants