var cleanTerm = global.encodeURIComponent(term); var url = 'http://en.wikipedia.org/w/api.php?...'; return Rx.Observable.getJSONPRequest(url); } // Get all distinct key up events from the input and var keyup = fromEvent(input, 'keyup') .map(e => e.target.value) .where(text => text.length > 2) // Longer than 2 chars .throttle(200) // Pause for 200ms .distinctUntilChanged(); // Only if the value has changed var doSearch = keyup .flatMap(text => searchWikipedia(text)) // Search wikipedia .switch() // Ensure no out of order results doSearch.subscribe(results => { // Do stuff with the results! });
return fromArray(['JavaScript', 'JavaServer Pages', 'JavaSoft', 'JavaScript library', 'JavaScript Object Notation', 'JavaScript engine', 'JavaScriptCore']); } // Get all distinct key up events from the input and var keyup = fromEvent(input, 'keyup') .map(e => e.target.value) .where(text => text.length > 2) // Longer than 2 chars .throttle(200) // Pause for 200ms .distinctUntilChanged(); // Only if the value has changed