Since rxjs-dom wasn't working I found another way.
Don't use rxjs-dom. It might be out of date. I went to use rxjs instead. Here's what I did (utilises jquery).
From my situation:
var search_bar = $("#search");
var textInput = $(search_bar);
var throttledInput =
Rx.Observable.fromEvent(textInput, 'keyup')
.pluck('target','value')
.filter( function (text) {
return text.length > 2;
})
.debounceTime(500)
.distinctUntilChanged();
var suggestions = throttledInput.switchMap(term => term ? this.search(term) : "no term");
suggestions.subscribe(
function (data)
{
console.log(data)
},
function (e)
{
console.log(e);
}
);
search(value)
{
return $.ajax({
type: "get",
url: "src/php/search.php",
data: {
name: value
}
}).promise();
}
First it gets the value from one of my inputs.
Then it turns it into an observable from the value.
debounceTime is used to prevent flooding the server if you're typing quickly
distinctUntilChange is used so only new results are sent
Lastly, it can utilise jquery, but must convert it back to promise.