Skip to content

Added support of custom transport#473

Closed
speedblue wants to merge 6 commits intotwitter:masterfrom
algolia:master
Closed

Added support of custom transport#473
speedblue wants to merge 6 commits intotwitter:masterfrom
algolia:master

Conversation

@speedblue
Copy link

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

@jharding
Copy link
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 jharding closed this Feb 9, 2014
@redox
Copy link

redox commented Feb 9, 2014

Awesome, thank you @jharding!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants