Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	examples/rx-autosuggest/directives/ac-autosuggest.ts
  • Loading branch information
chriscurnow committed Oct 24, 2015
2 parents bc49e81 + 9bb2871 commit b11b973
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/game-tictactoe/components/board/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import {Component, View, EventEmitter, CORE_DIRECTIVES} from 'angular2/angular2';

@Component({
selector: 'board',
properties: [ 'board' ],
events: [ 'select' ]
selector: 'board',
inputs: [ 'board' ],
outputs: [ 'select' ]
})
@View({
directives: [ CORE_DIRECTIVES ],
Expand Down
10 changes: 6 additions & 4 deletions examples/rx-autosuggest/directives/ac-autosuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import * as Rx from '@reactivex/rxjs';
import {GithubService} from '../services/GithubService';


declare var zone: Zone;

@Directive({
selector: 'input[type=text][ac-autosuggest-github]',
events: [ 'results', 'loading' ],
outputs: [ 'results', 'loading' ],
bindings: [ GithubService ]
})
export class AcAutosuggestGithub {
Expand All @@ -27,13 +29,13 @@ export class AcAutosuggestGithub {
// Lifecycle hook
onInit() {

(<any>Rx).Observable.fromEvent(this.el.nativeElement, 'input')
(<any>Rx).Observable.fromEvent(this.el.nativeElement, 'keyup')
.map(e => e.target.value) // Project the text from the input
.filter(text => text.length > 2) // Only if the text is longer than 2 characters
.debounce(250) // Pause for 250ms
.debounceTime(250) // Pause for 250ms
.distinctUntilChanged() // Only if the value has changed
.do(zone.bind(() => this.loading.next(true)))
.flatMapLatest(query => this.github.search(query)) // send query to search service
.flatMap(query => this.github.search(query)) // send query to search service
.do(zone.bind(() => this.loading.next(false)))
// here is the real action
.subscribe(
Expand Down
1 change: 0 additions & 1 deletion examples/rx-autosuggest/services/GithubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class GithubService {
*/
search(query: string): Rx.Observable<any[]> {
return this.http.get(this.url + query)
.toRx() // convert it to pure Rx stream
.map(res => res.json()) // make json
.map(res => res.items) // extract "items" only
.filter(repos => repos); // only if there are results
Expand Down

0 comments on commit b11b973

Please sign in to comment.