Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Debouncing of Searchbar #5429

Closed
vswarte opened this issue Feb 11, 2016 · 6 comments
Closed

feat: Debouncing of Searchbar #5429

vswarte opened this issue Feb 11, 2016 · 6 comments
Assignees
Milestone

Comments

@vswarte
Copy link

vswarte commented Feb 11, 2016

Type: feat

Ionic Version: 2.x

Platform: mobile webview

I've not seen debouncing described in the docs. So I'm just assuming this isn't implemented yet.

I'm currently making a bunch of API call's using the ion-searchbar as the input for a search query. But firing a call everytime someone is correcting their input is madness. Implementing this myself is rather cumbersome, and I'd love to see some opinionated way of debouncing "custom" inputs.

@alexbainbridge
Copy link

In researching the same thing, I found this https://manuel-rauber.com/2015/12/31/debouncing-angular-2-input-component/
Would be great to have built in somehow...

@alexbainbridge
Copy link

@BetaBugish Think that that is V1, but not sure!

@brandyscarney brandyscarney self-assigned this Feb 12, 2016
@brandyscarney brandyscarney added this to the 2.0.0-beta.1 milestone Feb 12, 2016
@jgw96
Copy link
Contributor

jgw96 commented Feb 14, 2016

@BetaBugish you could use RxJS debounce() and throttle()?

@abierbaum
Copy link

@alexbainbridge @BetaBugish You can use ngFormControl to do this the same way you would in a standard ng2 application.

Something along these lines should work:

import {Page} from 'ionic-framework/ionic';
import {Control} from 'angular2/common';

@Page({
   template: `
  <ion-content>
  <ion-searchbar  [ngFormControl]="searchControl"> </ion-searchbar>
</ion-content>
`
})
export class MyPage {
   searchControl: Control = new Control('');

   ngOnInit() {
      this.searchControl.valueChanges
            .debounceTime(500)
            .subscribe((term: string) => console.log('term: ' + term));
   }
}

@brandyscarney
Copy link
Member

Moving to beta.3, will discuss with the Angular team tomorrow.

adamdbradley added a commit that referenced this issue Mar 4, 2016
@adamdbradley
Copy link
Contributor

Added a debounce property that defaults to 250ms. Thanks everyone.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants