Skip to content

Commit

Permalink
Bloodhound optionally indexes/matches remote data
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotte-miller authored and Jake Harding committed Apr 27, 2015
1 parent 33ab953 commit 5b70c60
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/bloodhound.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ When configuring `remote`, the following options are available.
you to transform the remote response before the Bloodhound instance operates
on it. Defaults to the [identity function].

* `indexResponse` – Adds the remote response to the index (combined with local
and prefetched data). Then returns filtered results based on the query. Defaults
to `false`.

<!-- section links -->

[identity function]: http://en.wikipedia.org/wiki/Identity_function
6 changes: 6 additions & 0 deletions src/bloodhound/bloodhound.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ var Bloodhound = (function() {
}) && nonDuplicates.push(r);
});

// #1148: Should Bloodhound index remote datums?
if (that.remote.indexResponse) {
that.index.add(nonDuplicates);
nonDuplicates = that.index.search(query);
}

async && async(nonDuplicates);
}
},
Expand Down
1 change: 1 addition & 0 deletions src/bloodhound/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var Remote = (function() {
this.url = o.url;
this.prepare = o.prepare;
this.transform = o.transform;
this.indexResponse = o.indexResponse;

this.transport = new Transport({
cache: o.cache,
Expand Down

0 comments on commit 5b70c60

Please sign in to comment.