Skip to content

Instantly share code, notes, and snippets.

@jrmlstf
Created October 30, 2017 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrmlstf/9731eb1f26a240073e307205f91c00da to your computer and use it in GitHub Desktop.
Save jrmlstf/9731eb1f26a240073e307205f91c00da to your computer and use it in GitHub Desktop.
private initSuggestionsMoreBtn(): void {
Observable.fromEvent(this.moreSuggestionsBtn.nativeElement, 'click')
.mapTo(this.stepSuggestions)
.scan((acc, cur) => {
return acc < this.suggestions.length ? acc + cur : this.initialLimitSuggestions;
}, this.initialLimitSuggestions)
.takeUntil(this.onDestroy$)
.subscribe(
res => {
this.limitSuggestions = res;
this.hasMoreSuggestions = (res < this.suggestions.length);
},
error => console.log('Error: ', error)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment