-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Added 'compute' value to the Dataset, along with corresponding unit tests #220
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
Added 'compute' value to the Dataset, along with corresponding unit tests #220
Conversation
|
It probably also bears mentioning that unlike This gives more flexibility, but likely also increases the effort and complexity of the user-side. A sophisticated user could replicate the As well, if both the |
|
Just for completeness, here is a trivial jsFiddle demonstrating the asynchronous and synchronous use. |
|
I tested the async computed field with the Google Places autocomplete. Works great! |
|
FYI I'm not going to accept this pull request. There's nothing wrong with it per se, but I'm in the process overhauling typeahead.js for v0.10 and it'll support this functionality only through a slightly different API. I'm leaving this open until v0.10 lands though because some people need this functionality right away and this seems like a solid solution to point them towards. Thanks @brianmhunt for the pull request and for pointing people to it when they ask about this sort of functionality. It's much appreciated. |
|
Thanks for the update @jharding and it's my pleasure. I look forward to the 0.10 branch landing to check out what you've got planned. Cheers. |
|
This pull request wasn't applied in favor of something different? |
|
An alternative was proposed for Typeahead version 0.10, but I am not sure what the status of development is. |
|
Got it working in v0.10: For some reason the header is rendered after the results, I haven't tracked down the cause yet. |
|
@brianmhunt Thanks for your great work. It works for me. |
|
Finally closing this now that v0.10 has been released. Appreciate the work @brianmhunt. |
computedfunction-argument as expected, the API for this pull is incompatible with the 0.10 branch of Typeahead.js.In other words, while this pull may tide you over, be prepared to refactor for 0.10 and onwards.
Regarding Issue #95, this pull implements a way to address the issue of arbitrary synchronous and asynchronous computed datasets. While it may not be what you had in mind or the direction you want to take, I hope it gives helpful food for thought.
If this were merged the datasets arguments would accept a new
computedargument. In the synchronous case that computed option takes a single argument, the query.An asynchronous version of
computedtakes two arguments - thequeryand adonecallback that the user calls with the results they wish to add to the suggestions.Note that the asynchronous version uses the same logic as
remoterequests to check for duplicate results, but the synchronous version does not do any checks for duplicates.Neither the synchronous nor asynchronous utilizes the typeahead caching. It is left to the user to determine if and how they want to cache results (I suspect some complex applications in particular may want to do caching and control over limited
localStorageresources themselves).I hope that proves useful and interesting. Cheers.