Added support of custom transport #473

Closed
wants to merge 6 commits into
from

Conversation

Projects
None yet
4 participants

Allow to plug a custom remote backend (for example a backend with authentification)

Contributor

jharding commented Feb 9, 2014

In v0.10.0, I made it possible to define your own remote transport. So if you wanted to just web sockets for whatever reason, you could do something like:

var source = new Bloodhound({
  remote: {
    url: '/remote',
    send: function(url, o, onSuccess, onError) {
      // use websockets
      // onSuccess should be invoked with the suggestions
      // onError should be invoked if something went wrong
    }
  }
});

source.initialize();

$('.typeahead').typeahead(null, {
  source: source
});

FYI, I'm actually renaming send to transport in v0.10.1 (which should go out tomorrow).

Also, in my implementation, you'll still get rate limiting and caching for free.

Thanks for the pull request and I apologize it took me so long to address it.

jharding closed this Feb 9, 2014

redox commented Feb 9, 2014

Awesome, thank you @jharding!

zapnap referenced this pull request in algolia/algoliasearch-client-javascript Feb 10, 2014

Closed

Update typeahead to v0.10 (fork no longer required) / integration examples #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment